bpo-37340: Remove PyMethod_ClearFreeList() and PyCFunction_ClearFreeList() (GH-17284)
![](https://secure.gravatar.com/avatar/cc7737cd64a84f1b5c61a160798e97ee.jpg?s=120&d=mm&r=g)
https://github.com/python/cpython/commit/4dedd0f0ddc5a983a57bf0105eb34f948a9... commit: 4dedd0f0ddc5a983a57bf0105eb34f948a91d2c4 branch: master author: Victor Stinner <vstinner@python.org> committer: GitHub <noreply@github.com> date: 2019-11-20T12:59:12+01:00 summary: bpo-37340: Remove PyMethod_ClearFreeList() and PyCFunction_ClearFreeList() (GH-17284) Remove PyMethod_ClearFreeList() and PyCFunction_ClearFreeList() functions: the free lists of bound method objects have been removed. Remove also _PyMethod_Fini() and _PyCFunction_Fini() functions. files: A Misc/NEWS.d/next/C API/2019-11-20-11-08-06.bpo-37340.JBQJMS.rst M Doc/whatsnew/3.9.rst M Include/classobject.h M Include/internal/pycore_pylifecycle.h M Include/methodobject.h M Modules/gcmodule.c M Objects/classobject.c M Objects/methodobject.c M Python/pylifecycle.c diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 542a031960013..281173edb895b 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -217,6 +217,7 @@ Build and C API Changes ``PyThreadState.recursion_depth`` field. Remove ``_Py_CheckRecursionLimit`` from the stable ABI. (Contributed by Victor Stinner in :issue:`38644`.) + * Add a new public :c:func:`PyObject_CallNoArgs` function to the C API, which calls a callable Python object without any arguments. It is the most efficient way to call a callable Python object without any argument. @@ -230,6 +231,10 @@ Build and C API Changes ``pyfpe.h`` from ``Py_LIMITED_API`` (stable API). (Contributed by Victor Stinner in :issue:`38835`.) +* Remove ``PyMethod_ClearFreeList()`` and ``PyCFunction_ClearFreeList()`` + functions: the free lists of bound method objects have been removed. + (Contributed by Inada Naoki and Victor Stinner in :issue:`37340`.) + Deprecated ========== diff --git a/Include/classobject.h b/Include/classobject.h index c83303c390055..840431a127691 100644 --- a/Include/classobject.h +++ b/Include/classobject.h @@ -33,8 +33,6 @@ PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); #define PyMethod_GET_SELF(meth) \ (((PyMethodObject *)meth) -> im_self) -PyAPI_FUNC(int) PyMethod_ClearFreeList(void); - typedef struct { PyObject_HEAD PyObject *func; diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h index b8d5e361b3c73..c837bcdbc03cc 100644 --- a/Include/internal/pycore_pylifecycle.h +++ b/Include/internal/pycore_pylifecycle.h @@ -59,9 +59,7 @@ extern PyStatus _PyGC_Init(PyThreadState *tstate); /* Various internal finalizers */ -extern void _PyMethod_Fini(void); extern void _PyFrame_Fini(void); -extern void _PyCFunction_Fini(void); extern void _PyDict_Fini(void); extern void _PyTuple_Fini(void); extern void _PyList_Fini(void); diff --git a/Include/methodobject.h b/Include/methodobject.h index 3bccf5a3f60d3..a15d05f89917e 100644 --- a/Include/methodobject.h +++ b/Include/methodobject.h @@ -97,8 +97,6 @@ typedef struct { } PyCFunctionObject; #endif -PyAPI_FUNC(int) PyCFunction_ClearFreeList(void); - #ifdef __cplusplus } #endif diff --git a/Misc/NEWS.d/next/C API/2019-11-20-11-08-06.bpo-37340.JBQJMS.rst b/Misc/NEWS.d/next/C API/2019-11-20-11-08-06.bpo-37340.JBQJMS.rst new file mode 100644 index 0000000000000..8ffa4eb12bd4e --- /dev/null +++ b/Misc/NEWS.d/next/C API/2019-11-20-11-08-06.bpo-37340.JBQJMS.rst @@ -0,0 +1,2 @@ +Remove ``PyMethod_ClearFreeList()`` and ``PyCFunction_ClearFreeList()`` +functions: the free lists of bound method objects have been removed. diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 967bbe9c0d45d..d232179a11ce4 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -1029,9 +1029,7 @@ delete_garbage(PyThreadState *tstate, GCState *gcstate, static void clear_freelists(void) { - (void)PyMethod_ClearFreeList(); (void)PyFrame_ClearFreeList(); - (void)PyCFunction_ClearFreeList(); (void)PyTuple_ClearFreeList(); (void)PyUnicode_ClearFreeList(); (void)PyFloat_ClearFreeList(); diff --git a/Objects/classobject.c b/Objects/classobject.c index d3fc726415406..db53f04862cd6 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -371,20 +371,6 @@ PyTypeObject PyMethod_Type = { method_new, /* tp_new */ }; -/* Clear out the free list */ - -int -PyMethod_ClearFreeList(void) -{ - return 0; -} - -void -_PyMethod_Fini(void) -{ - (void)PyMethod_ClearFreeList(); -} - /* ------------------------------------------------------------------------ * instance method */ diff --git a/Objects/methodobject.c b/Objects/methodobject.c index 8f752c610ce4b..6a37238d86d8d 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -313,21 +313,6 @@ PyTypeObject PyCFunction_Type = { 0, /* tp_dict */ }; -/* Clear out the free list */ - -int -PyCFunction_ClearFreeList(void) -{ - return 0; -} - -void -_PyCFunction_Fini(void) -{ - (void)PyCFunction_ClearFreeList(); -} - - /* Vectorcall functions for each of the PyCFunction calling conventions, * except for METH_VARARGS (possibly combined with METH_KEYWORDS) which * doesn't use vectorcall. diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 2149dbf569d6b..44a4b18590b4b 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1173,9 +1173,7 @@ finalize_interp_types(PyThreadState *tstate, int is_main_interp) { if (is_main_interp) { /* Sundry finalizers */ - _PyMethod_Fini(); _PyFrame_Fini(); - _PyCFunction_Fini(); _PyTuple_Fini(); _PyList_Fini(); _PySet_Fini();
participants (1)
-
Victor Stinner