bpo-40170: PyObject_NEW() becomes an alias to PyObject_New() by vstinner · Pull Request #19379 · python/cpython (original) (raw)
The PyObject_NEW() macro becomes an alias to the PyObject_New()
macro, and the PyObject_NEW_VAR() macro becomes an alias to the
PyObject_NewVar() macro, to hide implementation details. They no
longer access directly the PyTypeObject.tp_basicsize member.
https://bugs.python.org/issue40170
Once this PR is merged, I plan to write following PR to remove _PyObject_SIZE() and the example using it.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, Victor
Previously, PyObject_NEW() macro already called PyObject_Init() function. It now calls _PyObject_New() which calls the inlined flavor PyObject_INIT(). I don't expect any impact on performance.
The PyObject_NEW() macro becomes an alias to the PyObject_New() macro, and the PyObject_NEW_VAR() macro becomes an alias to the PyObject_NewVar() macro, to hide implementation details. They no longer access directly the PyTypeObject.tp_basicsize member.
Move _PyObject_SIZE() and _PyObject_VAR_SIZE() macros to the CPython-specific C API (Include/cpython/).
Replace PyObject_NEW() with PyObject_New() and replace PyObject_NEW_VAR() with PyObject_NewVar().
vstinner changed the title
bpo-40170: PyObject_NEW() now calls _PyObject_New() bpo-40170: PyObject_NEW() becomes an alias to PyObject_New()