8000 Add News and Fix MSVC Build · python/cpython@51e4879 · GitHub
[go: up one dir, main page]

Skip to content

Commit 51e4879

Browse files
Add News and Fix MSVC Build
1 parent c6a1bfa commit 51e4879

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This introduces Immortal Instances which allows the user to bypass reference
2+
counting and avoid CoW on forked processes.

Modules/gcmodule.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,6 @@ gc_get_freeze_count_impl(PyObject *module)
19391939
return gc_list_size(&gcstate->permanent_generation.head);
19401940
}
19411941

1942-
#ifdef Py_IMMORTAL_INSTANCES
19431942

19441943
/*[clinic input]
19451944
gc.is_immortal -> bool
@@ -1954,10 +1953,15 @@ static int
19541953
gc_is_immortal_impl(PyObject *module, PyObject *instance)
19551954
/*[clinic end generated code: output=743a163cb6aaf384 input=815182ca5c5d81e4]*/
19561955
{
1956+
#ifdef Py_IMMORTAL_INSTANCES
19571957
return _Py_IsImmortal(instance);
1958+
#else
1959+
return 0;
1960+
#endif /* Py_IMMORTAL_INSTANCES */
19581961
}
19591962

19601963

1964+
#ifdef Py_IMMORTAL_INSTANCES
19611965
static int
19621966
immortalize_object(PyObject *obj, PyObject *Py_UNUSED(ignored))
19631967
{
@@ -1977,6 +1981,7 @@ immortalize_object(PyObject *obj, PyObject *Py_UNUSED(ignored))
19771981
}
19781982
return 0;
19791983
}
1984+
#endif /* Py_IMMORTAL_INSTANCES */
19801985

19811986
/*[clinic input]
19821987
gc.immortalize_heap
@@ -1988,6 +1993,7 @@ static PyObject *
19881993
gc_immortalize_heap_impl(PyObject *module)
19891994
/*[clinic end generated code: output=a7bb85fe2e27e4ae input=ca1709e4667c0623]*/
19901995
{
1996+
#ifdef Py_IMMORTAL_INSTANCES
19911997
PyGC_Head *gc, *list;
19921998
PyThreadState *tstate = _PyThreadState_GET();
19931999
GCState *gcstate = &tstate->interp->gc;
@@ -2012,10 +2018,10 @@ gc_immortalize_heap_impl(PyObject *module)
20122018
Py_TYPE(FROM_GC(gc))->tp_traverse(
20132019
FROM_GC(gc), (visitproc)immortalize_object, NULL);
20142020
}
2021+
#endif /* Py_IMMORTAL_INSTANCES */
20152022
Py_RETURN_NONE;
20162023
}
20172024

2018-
#endif /* Py_IMMORTAL_INSTANCES */
20192025

20202026
PyDoc_STRVAR(gc__doc__,
20212027
"This module provides access to the garbage collector for reference cycles.\n"
@@ -2035,10 +2041,8 @@ PyDoc_STRVAR(gc__doc__,
20352041
"is_finalized() A41F -- Returns true if a given object has been already finalized.\n"
20362042
"get_referrers() -- Return the list of objects that refer to an object.\n"
20372043
"get_referents() -- Return the list of objects that an object refers to.\n"
2038-
#ifdef Py_IMMORTAL_INSTANCES
20392044
"immortalize_heap() -- Immortalize all instances accessible through the GC roots.\n"
20402045
"is_immortal() -- Check if an object has been immortalized.\n"
2041-
#endif /* Py_IMMORTAL_INSTANCES */
20422046
"freeze() -- Freeze all tracked objects and ignore them for future collections.\n"
20432047
"unfreeze() -- Unfreeze all objects in the permanent generation.\n"
20442048
"get_freeze_count() -- Return the number of objects in the permanent generation.\n");
@@ -2064,10 +2068,8 @@ static PyMethodDef GcMethods[] = {
20642068
GC_FREEZE_METHODDEF
20652069
GC_UNFREEZE_METHODDEF
20662070
GC_GET_FREEZE_COUNT_METHODDEF
2067-
#ifdef Py_IMMORTAL_INSTANCES
20682071
GC_IMMORTALIZE_HEAP_METHODDEF
20692072
GC_IS_IMMORTAL_METHODDEF
2070-
#endif
20712073
{NULL, NULL} /* Sentinel */
20722074
};
20732075

0 commit comments

Comments
 (0)
0