Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner commented Jan 27, 2022

Convert the PyType_SUPPORTS_WEAKREFS() macro to a regular function.
It no longer access the PyTypeObject.tp_weaklistoffset member
directly.

Add _PyType_SUPPORTS_WEAKREFS() static inline functions, used
internally by Python for best performances.

https://bugs.python.org/issue40170

@vstinner
Copy link
MemberAuthor

I cannot find "PyType_SUPPORTS_WEAKREFS" in the source code of top 5000 PyPI projects.

Convert the PyType_SUPPORTS_WEAKREFS() macro to a regular function. It no longer access the PyTypeObject.tp_weaklistoffset member directly. Add _PyType_SUPPORTS_WEAKREFS() static inline functions, used internally by Python for best performances.
@vstinnervstinner marked this pull request as ready for review January 27, 2022 01:44
@vstinner
Copy link
MemberAuthor

This change has no impact on performance (Python internals continue accessing directly the PyTypeObject) and no impact on the API (the function remains available in the public C API).

@vstinnervstinner merged commit af32b3e into python:mainJan 27, 2022
@vstinnervstinner deleted the type_supports_weakref branch January 27, 2022 02:00
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@vstinner@the-knights-who-say-ni@bedevere-bot