New submission from STINNER Victor <vstin...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue40989> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com