Skip to content

Commit 4dedd0f

Browse files
authored
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.
1 parent 7247407 commit 4dedd0f

File tree

9 files changed

+7
-39
lines changed

9 files changed

+7
-39
lines changed

Doc/whatsnew/3.9.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ Build and C API Changes
217217
``PyThreadState.recursion_depth`` field. Remove ``_Py_CheckRecursionLimit``
218218
from the stable ABI.
219219
(Contributed by Victor Stinner in :issue:`38644`.)
220+
220221
* Add a new public :c:func:`PyObject_CallNoArgs` function to the C API, which
221222
calls a callable Python object without any arguments. It is the most efficient
222223
way to call a callable Python object without any argument.
@@ -230,6 +231,10 @@ Build and C API Changes
230231
``pyfpe.h`` from ``Py_LIMITED_API`` (stable API).
231232
(Contributed by Victor Stinner in :issue:`38835`.)
232233

234+
* Remove ``PyMethod_ClearFreeList()`` and ``PyCFunction_ClearFreeList()``
235+
functions: the free lists of bound method objects have been removed.
236+
(Contributed by Inada Naoki and Victor Stinner in :issue:`37340`.)
237+
233238

234239
Deprecated
235240
==========

Include/classobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
3333
#define PyMethod_GET_SELF(meth) \
3434
(((PyMethodObject *)meth) -> im_self)
3535

36-
PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
37-
3836
typedef struct {
3937
PyObject_HEAD
4038
PyObject *func;

Include/internal/pycore_pylifecycle.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ extern PyStatus _PyGC_Init(PyThreadState *tstate);
5959

6060
/* Various internal finalizers */
6161

62-
extern void _PyMethod_Fini(void);
6362
extern void _PyFrame_Fini(void);
64-
extern void _PyCFunction_Fini(void);
6563
extern void _PyDict_Fini(void);
6664
extern void _PyTuple_Fini(void);
6765
extern void _PyList_Fini(void);

Include/methodobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ typedef struct {
9797
} PyCFunctionObject;
9898
#endif
9999

100-
PyAPI_FUNC(int) PyCFunction_ClearFreeList(void);
101-
102100
#ifdef __cplusplus
103101
}
104102
#endif
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove ``PyMethod_ClearFreeList()`` and ``PyCFunction_ClearFreeList()``
2+
functions: the free lists of bound method objects have been removed.

Modules/gcmodule.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,9 +1029,7 @@ delete_garbage(PyThreadState *tstate, GCState *gcstate,
10291029
static void
10301030
clear_freelists(void)
10311031
{
1032-
(void)PyMethod_ClearFreeList();
10331032
(void)PyFrame_ClearFreeList();
1034-
(void)PyCFunction_ClearFreeList();
10351033
(void)PyTuple_ClearFreeList();
10361034
(void)PyUnicode_ClearFreeList();
10371035
(void)PyFloat_ClearFreeList();

Objects/classobject.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -371,20 +371,6 @@ PyTypeObject PyMethod_Type = {
371371
method_new, /* tp_new */
372372
};
373373

374-
/* Clear out the free list */
375-
376-
int
377-
PyMethod_ClearFreeList(void)
378-
{
379-
return 0;
380-
}
381-
382-
void
383-
_PyMethod_Fini(void)
384-
{
385-
(void)PyMethod_ClearFreeList();
386-
}
387-
388374
/* ------------------------------------------------------------------------
389375
* instance method
390376
*/

Objects/methodobject.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -313,21 +313,6 @@ PyTypeObject PyCFunction_Type = {
313313
0, /* tp_dict */
314314
};
315315

316-
/* Clear out the free list */
317-
318-
int
319-
PyCFunction_ClearFreeList(void)
320-
{
321-
return 0;
322-
}
323-
324-
void
325-
_PyCFunction_Fini(void)
326-
{
327-
(void)PyCFunction_ClearFreeList();
328-
}
329-
330-
331316
/* Vectorcall functions for each of the PyCFunction calling conventions,
332317
* except for METH_VARARGS (possibly combined with METH_KEYWORDS) which
333318
* doesn't use vectorcall.

Python/pylifecycle.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,7 @@ finalize_interp_types(PyThreadState *tstate, int is_main_interp)
11731173
{
11741174
if (is_main_interp) {
11751175
/* Sundry finalizers */
1176-
_PyMethod_Fini();
11771176
_PyFrame_Fini();
1178-
_PyCFunction_Fini();
11791177
_PyTuple_Fini();
11801178
_PyList_Fini();
11811179
_PySet_Fini();

0 commit comments

Comments
 (0)