diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 542a0319600..281173edb89 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 c83303c3900..840431a1276 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 b8d5e361b3c..c837bcdbc03 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 3bccf5a3f60..a15d05f8991 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 00000000000..8ffa4eb12bd --- /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 967bbe9c0d4..d232179a11c 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 d3fc7264154..db53f04862c 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 8f752c610ce..6a37238d86d 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 2149dbf569d..44a4b18590b 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();