mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
bpo-45953: Statically allocate the main interpreter (and initial thread state). (gh-29883)
Previously, the main interpreter was allocated on the heap during runtime initialization. Here we instead embed it into _PyRuntimeState, which means it is statically allocated as part of the _PyRuntime global. The same goes for the initial thread state (of each interpreter, including the main one). Consequently there are fewer allocations during runtime/interpreter init, fewer possible failures, and better memory locality. FYI, this also helps efforts to consolidate globals, which in turns helps work on subinterpreter isolation. https://bugs.python.org/issue45953
This commit is contained in:
parent
0bbf30e2b9
commit
ed57b36c32
8 changed files with 115 additions and 34 deletions
|
@ -617,7 +617,7 @@ Py_AddPendingCall(int (*func)(void *), void *arg)
|
|||
}
|
||||
else {
|
||||
/* Last resort: use the main interpreter */
|
||||
interp = _PyRuntime.interpreters.main;
|
||||
interp = _PyInterpreterState_Main();
|
||||
}
|
||||
return _PyEval_AddPendingCall(interp, func, arg);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue