mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-81057: Move the Extension Modules Cache to _PyRuntimeState (gh-99355)
We also move the closely related max_module_number and add comments documenting the group of struct members. https://github.com/python/cpython/issues/81057
This commit is contained in:
parent
fe55ff3f68
commit
dd36b71fa6
7 changed files with 104 additions and 33 deletions
|
|
@ -123,6 +123,25 @@ struct _is {
|
|||
|
||||
// sys.modules dictionary
|
||||
PyObject *modules;
|
||||
/* This is the list of module objects for all legacy (single-phase init)
|
||||
extension modules ever loaded in this process (i.e. imported
|
||||
in this interpreter or in any other). Py_None stands in for
|
||||
modules that haven't actually been imported in this interpreter.
|
||||
|
||||
A module's index (PyModuleDef.m_base.m_index) is used to look up
|
||||
the corresponding module object for this interpreter, if any.
|
||||
(See PyState_FindModule().) When any extension module
|
||||
is initialized during import, its moduledef gets initialized by
|
||||
PyModuleDef_Init(), and the first time that happens for each
|
||||
PyModuleDef, its index gets set to the current value of
|
||||
a global counter (see _PyRuntimeState.imports.last_module_index).
|
||||
The entry for that index in this interpreter remains unset until
|
||||
the module is actually imported here. (Py_None is used as
|
||||
a placeholder.) Note that multi-phase init modules always get
|
||||
an index for which there will never be a module set.
|
||||
|
||||
This is initialized lazily in _PyState_AddModule(), which is also
|
||||
where modules get added. */
|
||||
PyObject *modules_by_index;
|
||||
// Dictionary of the sys module
|
||||
PyObject *sysdict;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue