Message371597
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. |
|
Date |
User |
Action |
Args |
2020-06-15 21:05:35 | vstinner | set | recipients:
+ vstinner |
2020-06-15 21:05:35 | vstinner | set | messageid: <1592255135.39.0.855912884014.issue40989@roundup.psfhosted.org> |
2020-06-15 21:05:35 | vstinner | link | issue40989 messages |
2020-06-15 21:05:35 | vstinner | create | |
|