mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +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
|
@ -9,7 +9,6 @@
|
|||
#include "pycore_moduleobject.h" // _PyModule_GetDef()
|
||||
#include "structmember.h" // PyMemberDef
|
||||
|
||||
static Py_ssize_t max_module_number;
|
||||
|
||||
static PyMemberDef module_members[] = {
|
||||
{"__dict__", T_OBJECT, offsetof(PyModuleObject, md_dict), READONLY},
|
||||
|
@ -43,10 +42,10 @@ PyModuleDef_Init(PyModuleDef* def)
|
|||
{
|
||||
assert(PyModuleDef_Type.tp_flags & Py_TPFLAGS_READY);
|
||||
if (def->m_base.m_index == 0) {
|
||||
max_module_number++;
|
||||
_PyRuntime.imports.last_module_index++;
|
||||
Py_SET_REFCNT(def, 1);
|
||||
Py_SET_TYPE(def, &PyModuleDef_Type);
|
||||
def->m_base.m_index = max_module_number;
|
||||
def->m_base.m_index = _PyRuntime.imports.last_module_index;
|
||||
}
|
||||
return (PyObject*)def;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue