[Python-ideas] PEP 554: Stdlib Module to Support Multiple Interpreters in Python Code

Nick Coghlan ncoghlan at gmail.com
Mon Sep 11 01:32:19 EDT 2017


On 11 September 2017 at 00:52, Koos Zevenhoven <k7hoven at gmail.com> wrote:
> On Thu, Sep 7, 2017 at 9:26 PM, Eric Snow <ericsnowcurrently at gmail.com>
> wrote:
> [...]
>
>>
>> get_main():
>>
>>    Return the main interpreter.
>>
>
> I assume the concept of a main interpreter is inherited from the previous
> levels of support in the C API, but what exactly is the significance of
> being "the main interpreter"? Instead, could they just all be
> subinterpreters of the same Python process (or whatever the right wording
> would be)?

The main interpreter is ultimately responsible for the actual process
global state: standard streams, signal handlers, dynamically linked
libraries, __main__ module, etc.

The line between it and the "CPython Runtime" is fuzzy for both
practical and historical reasons, but the regular Python CLI will
always have a "first created, last destroyed" main interpreter, simply
because we don't really gain anything significant from eliminating it
as a concept.

By contrast, embedding applications that *don't* have a __main__
module, and already manage most process global state themselves
without the assistance of the CPython Runtime can already get pretty
close to just having a pool of peer subinterpreters, and will
presumably be able to get closer over time as the subinterpreter
support becomes more robust.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list