mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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
|
@ -292,7 +292,7 @@ trip_signal(int sig_num)
|
|||
_Py_atomic_store(&is_tripped, 1);
|
||||
|
||||
/* Signals are always handled by the main interpreter */
|
||||
PyInterpreterState *interp = _PyRuntime.interpreters.main;
|
||||
PyInterpreterState *interp = _PyInterpreterState_Main();
|
||||
|
||||
/* Notify ceval.c */
|
||||
_PyEval_SignalReceived(interp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue