]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-45953: Statically allocate the main interpreter (and initial thread state). ...
authorEric Snow <ericsnowcurrently@gmail.com>
Wed, 12 Jan 2022 23:28:46 +0000 (16:28 -0700)
committerGitHub <noreply@github.com>
Wed, 12 Jan 2022 23:28:46 +0000 (16:28 -0700)
commited57b36c32e521162dbb97199e64a340d3bff827
treefab825ae903723e4dc748e7b89cb78f3b226c816
parent0bbf30e2b910bc9c5899134ae9d73a8df968da35
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
Include/cpython/pystate.h
Include/internal/pycore_global_objects.h
Include/internal/pycore_interp.h
Include/internal/pycore_runtime.h
Misc/NEWS.d/next/Core and Builtins/2021-12-01-11-54-27.bpo-45953.2znR0E.rst [new file with mode: 0644]
Modules/signalmodule.c
Python/ceval.c
Python/pystate.c