Skip to content

PEP 670: Convert static inline functions to functions #97016

Closed
@vstinner

Description

@vstinner

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions