On Tue, Sep 12, 2017 at 1:40 PM, Nick Coghlan <ncoghlan@gmail.com> wrote:
On 11 September 2017 at 18:02, Koos Zevenhoven <k7hoven@gmail.com> wrote:
> On Mon, Sep 11, 2017 at 8:32 AM, Nick Coghlan <ncoghlan@gmail.com> wrote:
>> 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.
> I fear that emphasizing the main interpreter will lead to all kinds of
> libraries/programs that somehow unnecessarily rely on some or all tasks
> being performed in the main interpreter. Then you'll have a hard time
> running two of them in parallel in the same process, because you don't have
> two main interpreters.

You don't need to fear this scenario, since it's a description of the
status quo (and it's the primary source of overstated claims about
subinterpreters being "fundamentally broken").

Well, if that's true, it's hardly a counter-argument to what I said. Anyway, there is no status quo about what is proposed in the PEP.

And as long as the existing APIs are preserved, why not make the new one less susceptible to overstated fundamental brokenness?

So no, not everything will be subinterpreter-friendly, just as not
everything in Python is thread-safe, and not everything is portable
across platforms.

I don't see how the situation benefits from calling something the "main interpreter".​ Subinterpreters can be a way to take something non-thread-safe and make it thread-safe, because in an interpreter-per-thread scheme, most of the state, like module globals, are thread-local. (Well, this doesn't help for async concurrency, but anyway.)
That's OK - it just means we'll aim to make as many
things as possible implicitly subinterpreter-friendly, and for
everything else, we'll aim to minimise the adjustments needed to
*make* things subinterpreter friendly.

​And that's exactly what I'm after here! 

I'm mostly just worried about the `get_main()` function. Maybe it should be called `asdfjaosjnoijb()`, so people wouldn't use it. Can't the first running interpreter just introduce itself to its children? And if that's too much to ask, maybe there could be a `get_parent()` function, which would give you the interpreter that spawned the current subinterpreter. 

Well OK, perhaps the current implementation only allows the "main interpreter" to spawn new interpreters (I have no idea). In that case, `get_parent()` will just be another, more future-proof name for `get_main()`. Then it would just need a clear documentation of the differences between the parent and its children. If the author of user code is not being too lazy, they might even read the docs and figure out if they *really* need to make a big deal out of which interpreter is the main/parent one.

Still, I'm not convinced that there needs to be a get_main or get_parent. It shouldn't be too hard for users to make a wrapper around the API that provides this functionality. And if they do that––and use it to make their code "fundamentally broken"––then... at least we tried.


+ Koos Zevenhoven + http://twitter.com/k7hoven +