-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage
Description
PyType_GetModuleByDef does a lot of work for what was a single memory read prior to sub-interpreters.
For example, #114682.
We should provide a more efficient way to get to the module state from the module def.
AFAICT, the function to get the module state is a pure function of the interpreter and the module def.
Since the module def already has a m_index field that is described as "The module's index into its interpreter's modules_by_index cache.", then a Py_GetModuleFromDef() function could be as simple as:
inline PyObject *
Py_GetModuleFromDef(PyModuleDef *def)
{
return PyInterpreterState_Get()->modules_table[def->m_base.m_index];
}Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage