Expand description
Process-global runtime support for multiple interpreters (PEP 734 preparation).
CPython maps roughly as:
- this module ≈
_PyRuntimeState.interpreters+ ID allocation crate::vm::PyGlobalState≈PyInterpreterStatecrate::VirtualMachine≈PyThreadState(plus shared refs to interpreter state)
Multiple crate::Interpreter instances can coexist in one process. Each owns
an isolated PyGlobalState (modules, codecs, thread registry, stop-the-world, …)
while sharing the process-wide crate::Context (builtin types / immortals).
Structs§
- Interp
Feature Flags - Feature flags copied from
PyInterpreterConfig/Py_RTFLAGS_*. - Interpreter
Config - Named
PyInterpreterConfigused by_interpreters.create/new_config. - Interpreter
Info - Snapshot of a registered interpreter for enumeration APIs.
Enums§
- Interpreter
Gil - Interpreter
Whence - Where an interpreter state came from (mirrors CPython
_PyInterpreterState_GetWhence).
Constants§
- MAIN_
INTERPRETER_ ID - Conventional id of the first process main interpreter when allocation is
sequential (CPython parity). Concurrent construction may assign other ids;
use
PyGlobalState::is_main/crate::Interpreter::is_mainto identify a main interpreter, not this constant alone. - SUPPORTS_
ISOLATED_ INTERPRETERS - Backs
sys.implementation.supports_isolated_interpreters.
Functions§
- interpreter_
count - Number of registered interpreters that are still alive.
- list_
interpreters - List all currently registered (still-alive) interpreters.
- live_
interpreter_ states - All live interpreter states, ordered by id.
- lookup_
interpreter - Look up a live interpreter state by id.
- main_
interpreter_ id - Id of the main interpreter (PEP 734
get_main()), orNonebefore any interpreter has been created.