PEP-0554 Multiple Interpreters in the Stdlib

Proposal

The interpreters module will be added to the stdlib.

To help authors of extension modules, a new page will be added to the Extending Python docs. More information on both is found in the immediately following sections.

The “interpreters” Module

The interpreters module will provide a high-level interface to subinterpreters and wrap a new low-level _interpreters (in the same way as the threading module).

See the Examples section for concrete usage and use cases.

Along with exposing the existing (in CPython) subinterpreter support, the module will also provide a mechanism for sharing data between interpreters .

This mechanism centers around channels , which are similar to queues and pipes.

Note that objects are not shared between interpreters since they are tied to the interpreter in which they were created.

Instead, the objects’ data is passed between interpreters.

See the Shared data section for more details about sharing between interpreters.

At first only the following types will be supported for sharing:

  • None

  • bytes

  • str

  • int

Support for other basic types (e.g. bool, float, Ellipsis) will be added later.