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 if
s (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_GetModule
is 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.