[New-bugs-announce] [issue40989] [C API] Remove _Py_NewReference() and _Py_ForgetReference() from the public C API
STINNER Victor
report at bugs.python.org
Mon Jun 15 17:05:35 EDT 2020
New submission from STINNER Victor <vstinner at python.org>:
The _Py_NewReference() and _Py_ForgetReference() functions are tightly coupled to CPython internals.
_Py_NewReference() is only exposed because it used by the PyObject_INIT() macro which is the fast inlined flavor of PyObject_Init(). If we make PyObject_INIT() as alias to PyObject_Init(), as already done for the limited C API, _Py_NewReference() can be removed from the public C API (moved to the internal C API).
_Py_ForgetReference() function is only defined if Py_TRACE_REFS macro is defined. I propose to also removed it from the public C API (move it to the internal C API).
In the CPython code base, _Py_NewReference() is used:
* to implement the free list optimization
* in _PyBytes_Resize() and unicode_resize() (resize_compact() to be precise)
* by PyObject_CallFinalizerFromDealloc() to resurrect an object
These are corner cases which can be avoided in third party C extension modules.
----------
components: C API
messages: 371597
nosy: vstinner
priority: normal
severity: normal
status: open
title: [C API] Remove _Py_NewReference() and _Py_ForgetReference() from the public C API
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40989>
_______________________________________
More information about the New-bugs-announce
mailing list