bpo-40170: PyType_HasFeature() no longer acccess directly tp_flags - #19378
Conversation
|
@serhiy-storchaka @methane: Do you expect such change to have an impact on performance? What do you think of the change? |
|
Some |
Yes, that's possible but I would prefer to add new functions to the internal C API for that. For example, add a fast In the past, I tried to reuse the same name for two implementation of the same function: one "slow" using a function call, one "fast" using a macro or static inline function. I'm thinking at PyThreadState_GET(). The internal C API uses: The problem is that depending if the internal C API is included or not, you may get the slow or the fast function. I changed my approach: use a different name for the fast function. |
PyType_HasFeature() now always calls PyType_GetFlags() to hide implementation details. Previously, it accessed directly the PyTypeObject.tp_flags member when the limited C API was not used. Add fast inlined version _PyType_HasFeature() and _PyType_IS_GC() for object.c and typeobject.c.
…gs() (pythonGH-19378)" (pythonGH-21390) This partially reverts commit 45ec5b9. (cherry picked from commit b26a0db) Co-authored-by: Victor Stinner <vstinner@python.org>
…gs() (pythonGH-19378)" (pythonGH-21390) This partially reverts commit 45ec5b9.
…gs() (pythonGH-19378)" (pythonGH-21390) This partially reverts commit 45ec5b9.

PyType_HasFeature() now always calls PyType_GetFlags() to hide
implementation details. Previously, it accessed directly the
PyTypeObject.tp_flags member when the limited C API was not used.
Add fast inlined version _PyType_HasFeature() and _PyType_IS_GC()
for object.c and typeobject.c.
https://bugs.python.org/issue40170