3 ms·
> They need some form of locking around Python objects accessed from multiple threads, since Python has no ownership model. "Ownership models" are not a given.
by ris 6y ago
> They need some form of locking around Python objects accessed from multiple threads, since Python has no ownership model.
"Ownership models" are not a given. C++ has no "ownership model" and it doesn't lock around objects. Multi-threading users are just given the synchronization primitives and are expected to manage their own solutions.
The same is true in Python: https://docs.python.org/3/library/threading.html#lock-objects https://docs.python.org/3/library/threading.html#lock-object... - in fact, if you're using objects simultaneously from multiple threads without using some sort of locking scheme, you're probably already in trouble...
The main thing that's keeping the GIL around is the reference-counting garbage collector. If your python implementation uses its own GC mechanism, it doesn't have this problem.
- sitkack 6y agoFreeBSD went through a similar issue back in the late 90s, early 2000s when they added pervasive multithreading into the kernel. The GIL isn't some halting problem level thing. As you allude to, Python could definitely decide to go multithreaded and add in the requisite locks. They haven't. I really wish that the PSF would * Make a spec * Break out the stdlib into a portable library, and by portable, something that can be shared across PyPy, Graal, Jython, etc. * ??? yes