PEP 734: Multiple Interpreters in the Stdlib

Thanks for saying so! That’s definitely the goal.

Yeah, I definitely want it to be more flexible. :smile:

Yep, that’s pretty accurate. I’ll make sure the PEP gets updated to make that more clear.

I’m currently working on a separate PEP for exactly that. :smile:

That’s a good point. Honestly, I was already considering falling back to pickle in interpreters.Queue. Here’s my main hesitation: I want a consistent explanation for the relationship between the send object and the received one. My preference for that relationship is “they may not be the exact same object, but they might as well be”. At the least, it’s an illusion I’d like to preserve. For immutable objects, that’s easy. For mutable ones, not so much.

Sharing mutable objects would either require that the underlying data is truly shared between the interpreters (a hard-ish problem) or that each interpreter have its own copy. The former would preserve my desired relationship between the objects. The latter would invalidate it unrecoverably. Pickling would mean the latter.

That said, having two distinct classes does seem like a way to preserve the constraint I want on a selective basis. I’ll think it over. It might also be doable as an optional flag on create_queue().

That’s a good observation. I’ll keep it in mind.

That’s a good point.

Partly it’s because queues live in the space between interpreters. create_queue() seemed to communicate that well. In contrast, Queue() creates an interpreter-specific object and might communicate the wrong thing.

That said, I had the idea for create_queue() (rather, its equivalent) over 6(?) years ago and haven’t thought about it much since. I might think of it differently if I consider it now. There also isn’t much of a technical reason for the separation at the point, especially since I recently changed Queue instances to be singletons (in each interpreter) and require that they match existing queues. I’ll have to think this over.

(FWIW, the same goes for interpreters.create() and `Interpreter’.)

:+1:

As @pitrou noted, that’s something users already have to manage, whether from Python code or in extension modules.

Yeah, that’s a cool idea. We’ve discussed it before. As you noted, it’s something to be addressed after this PEP. You’re right about awareness affecting design though. Thanks for bringing this up.

1 Like