diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2022-01-12 16:28:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-12 16:28:46 -0700 |
commit | ed57b36c32e521162dbb97199e64a340d3bff827 (patch) | |
tree | fab825ae903723e4dc748e7b89cb78f3b226c816 /Python/ceval.c | |
parent | 0bbf30e2b910bc9c5899134ae9d73a8df968da35 (diff) | |
download | cpython-ed57b36c32e521162dbb97199e64a340d3bff827.tar.gz cpython-ed57b36c32e521162dbb97199e64a340d3bff827.zip |
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
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 8e878cbf7e2..d33cd4e1edb 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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); } |