STINNER Victor <vstin...@python.org> added the comment:
There are different problems. _Py_Dealloc() calls _Py_ForgetReference() and requires access to PyTypeObjects structure fields to call Py_TYPE(op)->tp_dealloc(). _Py_ForgetReference() is a function and so has no issuse with the limited API (it's not a macro nor an inline function). _Py_NewReference(): * _Py_NewReference() access _Py_tracemalloc_config, _Py_RefTotal and calls _Py_AddToAllObjects() * PyObject_INIT() and PyObject_INIT_VAR() inline functions call _Py_NewReference() I'm not sure that it's really more efficient than _Py_NewReference() and _Py_Dealloc() are macros/inline functions. Moreover, it causes issues with the limited API and it leaks many implementation details in the API. I may be better to convert PyObject_INIT() and PyObject_INIT_VAR() to aliases to public opaque PyObject_Init() and PyObject_InitVar(), and convert _Py_NewReference() and _Py_Dealloc() to opaque functions (from the API point of view). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39543> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com