Description
PEP 670 converted macros to static inline functions in Python 3.11. I propose to implement the second phase of PEP 670: convert static inline functions to regular functions in Python 3.12.
Static inline functions are causing C++ warnings. I had to add _Py_CAST() and _Py_NULL macros to Python 3.11 to limit the number of C++ warnings. The _Py_CAST() macro has a complicated history. @serge-sans-paille helped me to write a correct C++ implementation of _Py_CAST(), but it had to be reverted to fix the issue #94731. See:
- gh-94731: Revert to C-style casts for _Py_CAST #94782
- gh-91321: Add _testcppext C++ extension #32175 (comment)
- gh-94731: Revert to C-style casts for _Py_CAST #94782
As explained in PEP 670, static inline functions cannot be used in programming languages other than C, and these functions cannot be loaded by loading the symbol from the Python library (libpython). For example, the vim text editor loads uses the Python C API by loading symbols.
Converting static inline functions also hides implementation details. When using regular function calls, at the ABI level, it's just a regular function call, the machine code doesn't access directly structure members. So we have more freedom to changes Python internals (like the structure).
This issue is not about changing Python internals. It's just about convert static inline functions to regular functions.