-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirperformancePerformance or resource usagePerformance or resource usagetopic-C-APItype-featureA feature request or enhancementA feature request or enhancement
Description
See topic on Discourse.
For CPython internal usage, we've got _PyModule_GetState, which is a fast variant of PyModule_GetState, the module check in the latter is simply an assert in the former.
For PyType_GetModuleState, there are three ifs (two of them implicitly in PyType_GetModule):
- check that the given type is a heap type
- check that the given type has an associated module
- check that the result of
PyType_GetModuleis notNULL
For stdlib core extension modules, all of these conditions are always true (AFAIK). With a fast static inlined variant, for example _PyType_GetModuleState, with a fast variant of PyType_GetModule inlined, where all three conditions are assert()ed, we can speed up a heap type methods that need to access module state.
Linked PRs
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirperformancePerformance or resource usagePerformance or resource usagetopic-C-APItype-featureA feature request or enhancementA feature request or enhancement