On 9/9/21 1:29 pm, Victor Stinner wrote:
Converting macros to static inline functions prepares the C API for opaque function calls, like: PyTypeObject* Py_TYPE(PyObject *op). In CPython, we can likely keep static inline functions (for best performance).
The advantage of using static inline functions is that other Python implementations have more freedom on how they implement Py_TYPE() and Py_SET_TYPE(). They don't have to implement Python objects exactly the same way than CPython does anymore.
Currently, it's simply impossible to implement the Python C API without copying CPython PyObject structure.
As long as these are static inline functions in CPython, PyPy will also implement these as static inline functions. Any time we have deviated from CPython without having a carefully designed interface (like HPy provides), we see that sooner or later it causes problems: either compatibility or performance suffers. If there are reasons for CPython to do this kind of refactoring, that is great, but in my opinion doing this neither helps nor hurts (other than more code churn) PyPy.
Matti