[issue40170] [C API] Make PyTypeObject structure an opaque structure in the public C API

STINNER Victor report at bugs.python.org
Fri Jan 28 09:19:20 EST 2022


STINNER Victor <vstinner at python.org> added the comment:

Changes already done:

* Macros converted to regular functions:
 
  * PyObject_GET_WEAKREFS_LISTPTR(); add internal inline _PyObject_GET_WEAKREFS_LISTPTR()
  * PyType_SUPPORTS_WEAKREFS(); add internal inline _PyType_SUPPORTS_WEAKREFS()
  * PyObject_CheckBuffer(); no fast internal API
  * PyObject_IS_GC(); no fast internal API
  * PyDescr_IsData(); no fast internal API

* Always implemented as a function, remove macro optimization in the non-limited API:

  * PyIter_Check(); no fast internal API
  * PyIndex_Check(); add internal inline _PyIndex_Check()
  * PyExceptionClass_Name(); no fast internal API

* Py_TRASHCAN_BEGIN() macro now calls _PyTrash_cond() function: no longer read directly tp_dealloc member
* PyObject_NEW() macro becomes an alias to PyObject_New()
* Remove PyHeapType_GET_MEMBERS() (move it to the internal C API)

PyType_HasFeature() is left unchanged since the change caused performance issue on macOS, whereas Python is not built with LTO.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40170>
_______________________________________


More information about the Python-bugs-list mailing list