Skip to main content

Module runtime

Module runtime 

Source
Expand description

Process-global runtime support for multiple interpreters (PEP 734 preparation).

CPython maps roughly as:

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§

InterpFeatureFlags
Feature flags copied from PyInterpreterConfig / Py_RTFLAGS_*.
InterpreterConfig
Named PyInterpreterConfig used by _interpreters.create / new_config.
InterpreterInfo
Snapshot of a registered interpreter for enumeration APIs.

Enums§

InterpreterGil
InterpreterWhence
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_main to 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()), or None before any interpreter has been created.