summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2024-02-10 00:57:04 (GMT)
committerGitHub <noreply@github.com>2024-02-10 00:57:04 (GMT)
commitd4d5bae1471788b345155e8e93a2fe4ab92d09dc (patch)
tree989f7efdc60aff606679d12b4f1853174dd4365d /Objects/object.c
parent564385612cdf72c2fa8e629a68225fb2cd3b3d99 (diff)
downloadcpython-d4d5bae1471788b345155e8e93a2fe4ab92d09dc.zip
cpython-d4d5bae1471788b345155e8e93a2fe4ab92d09dc.tar.gz
cpython-d4d5bae1471788b345155e8e93a2fe4ab92d09dc.tar.bz2
gh-111968: Refactor _PyXXX_Fini to integrate with _PyObject_ClearFreeLists (gh-114899)
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 61e6131..275aa671 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -793,6 +793,21 @@ PyObject_Bytes(PyObject *v)
return PyBytes_FromObject(v);
}
+void
+_PyObject_ClearFreeLists(_PyFreeListState *state, int is_finalization)
+{
+ // In the free-threaded build, freelists are per-PyThreadState and cleared in PyThreadState_Clear()
+ // In the default build, freelists are per-interpreter and cleared in finalize_interp_types()
+ _PyFloat_ClearFreeList(state, is_finalization);
+ _PyTuple_ClearFreeList(state, is_finalization);
+ _PyList_ClearFreeList(state, is_finalization);
+ _PyDict_ClearFreeList(state, is_finalization);
+ _PyContext_ClearFreeList(state, is_finalization);
+ _PyAsyncGen_ClearFreeLists(state, is_finalization);
+ // Only be cleared if is_finalization is true.
+ _PyObjectStackChunk_ClearFreeList(state, is_finalization);
+ _PySlice_ClearFreeList(state, is_finalization);
+}
/*
def _PyObject_FunctionStr(x):