gh-89653: PEP 670: Convert PyCFunction macros to functions#92302
Conversation
It seems like it was missed when PEP 573 was implemented in Python 3.9: cc @encukou @ericsnowcurrently @ncoghlan |
|
Hm, |
Convert the following macros to static inline functions: * PyCFunction_GET_CLASS() * PyCFunction_GET_FLAGS() * PyCFunction_GET_FUNCTION() * PyCFunction_GET_SELF() Limited C API version 3.11 no longer casts arguments.
Ah. In that change, I leave it unchanged in my PR which is unrelated.
The problem with macros and static inline functions is that they are not usable in some programming languages, and they usually leak too many implementation details to be part of the limited C API. Since each PyCFunction macro or static inline function is paired with a regular function, to me, it looked consistent to expose PyCMethod_GetClass(). But it's up to you ;-) I'm thinking about deprecating macros and static inline functions, and maybe later make them an alias of their related function. I already did for PyThreadState_GET() which now just calls PyThreadState_Get(). IMO these macros and static inline functions only exist for best performance for CPython internals, but the benefits of using them outside CPython is not significant (in terms of performance). They make sense in the internal C API, not for the regular public C API. But well, that's a whole different topic, I should run benchmarks and write a PEP ;-) |
Oh, I'm not insisting on this being a macro. But the function should be |
Convert the following macros to static inline functions:
Limited C API version 3.11 no longer casts arguments.
Export the PyCMethod_GetClass() function.