Re:No-GIL mode coming for Python
by thayne on Saturday July 29, 2023 @10:36AM
(#36920730)
> two processes sharing state through a shared memory
The point is that isn't very practical, especially in python. In practice, any data passed between processes must be serialized and deserialized over a pipe or in shared memory. With a thread per interpreter, native python objecta could potentially be shared across threads/interpreters as long as there was adequate synchronization. Technically, you could also do that with shared memory with multiprocessing, but it would be harder, and you would need to specify the object is intended to be shared from the beginning.
> pretty much indistinguishable, at least on Linux.
Linux isn't the only OS people use python on.
> I would argue that shared mutable state is rarely a good idea, and an equivalent message based system is often preferable.
I agree, but even for message passing, having to serialize and deserialize the object across process boundaries hurts performance.
The point is that isn't very practical, especially in python. In practice, any data passed between processes must be serialized and deserialized over a pipe or in shared memory. With a thread per interpreter, native python objecta could potentially be shared across threads/interpreters as long as there was adequate synchronization. Technically, you could also do that with shared memory with multiprocessing, but it would be harder, and you would need to specify the object is intended to be shared from the beginning.
> pretty much indistinguishable, at least on Linux.
Linux isn't the only OS people use python on.
> I would argue that shared mutable state is rarely a good idea, and an equivalent message based system is often preferable.
I agree, but even for message passing, having to serialize and deserialize the object across process boundaries hurts performance.