-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-101476: Add _PyType_GetModuleState #101477
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
gh-101476: Add _PyType_GetModuleState #101477
Conversation
For fast module state access from heap type methods.
I'm not sure we should add a NEWS entry for this; this is an internal C API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Co-authored-by: Kumar Aditya <[email protected]>
Thanks for the review, Kumar! Even though I also got thumbs-up from Guido og Steve on Discourse, I'd like to wait for at least one other core dev approval before landing this PR. |
+1 from me, could you just add a comment to clarify the intent, e.g. |
Thanks for the review, Petr. I'll add the comment right away. |
Status check is done, and it's a success ✅. |
Thanks for the reviews, everyone! I'm applying this across the core extension modules. See #102188. |
PyHeapTypeObject *et = (PyHeapTypeObject *)type; | ||
assert(et->ht_module); | ||
PyModuleObject *mod = (PyModuleObject *)(et->ht_module); | ||
assert(mod != NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion is the same than assert(et->ht_module);
, no? If you only keep one, I suggest keeping assert(mod != NULL);
since we use mod below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... or the first assert could be changed to assert(et != NULL)
.
For fast module state access from heap type methods.
For fast module state access from heap type methods.