From ed57b36c32e521162dbb97199e64a340d3bff827 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 12 Jan 2022 16:28:46 -0700 Subject: 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 --- Python/ceval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/ceval.c') 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); } -- cgit v1.2.3