This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2020-06-15.21:05:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1592255135.39.0.855912884014.issue40989@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-06-15 21:05:35vstinnersetrecipients: + vstinner
2020-06-15 21:05:35vstinnersetmessageid: <1592255135.39.0.855912884014.issue40989@roundup.psfhosted.org>
2020-06-15 21:05:35vstinnerlinkissue40989 messages
2020-06-15 21:05:35vstinnercreate