-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-40170: PyType_HasFeature() no longer acccess directly tp_flags #19378
Conversation
I expect no significant performance difference or a very low overhead for macros and functions using PyType_HasFeature(). PyType_HasFeature() is used by the following code in header files:
PyType_FastSubclass() is used by many PyXXX_Check() macros:
|
@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.
@methane: I added 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.
…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