From 4dedd0f0ddc5a983a57bf0105eb34f948a91d2c4 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 20 Nov 2019 12:59:12 +0100 Subject: 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. --- Doc/whatsnew/3.9.rst | 5 +++++ Include/classobject.h | 2 -- Include/internal/pycore_pylifecycle.h | 2 -- Include/methodobject.h | 2 -- .../next/C API/2019-11-20-11-08-06.bpo-37340.JBQJMS.rst | 2 ++ Modules/gcmodule.c | 2 -- Objects/classobject.c | 14 -------------- Objects/methodobject.c | 15 --------------- Python/pylifecycle.c | 2 -- 9 files changed, 7 insertions(+), 39 deletions(-) create mode 100644 Misc/NEWS.d/next/C API/2019-11-20-11-08-06.bpo-37340.JBQJMS.rst diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 542a031..281173e 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 c83303c..840431a 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 b8d5e36..c837bcd 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 3bccf5a..a15d05f 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 0000000..8ffa4eb --- /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 967bbe9..d232179 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 d3fc726..db53f04 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 8f752c6..6a37238 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 2149dbf..44a4b18 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(); -- cgit v0.12