4 ms·
there is essentially no such thing as threads in python, unless I am completely missing something. The default python interpreter does absolutely nothing to ma
by grandinj 8y ago
there is essentially no such thing as threads in python, unless I am completely missing something.
The default python interpreter does absolutely nothing to make it's execution thread-safe, and that appears to be a deliberate decision on their part to keep the complexity of the interpreter down.
- bakery2k 8y agoOn the contrary, the Global Interpreter Lock provides many thread-safety guarantees. These are based on the fact that threads can only be interrupted between, not within, byte code instructions. For example, a single list can safely be extended (as in `l += [1]`) concurrently from several threads.
- grandinj 8y agoAh, you are correct, it's the non-threadedness of the interpreter itself I was thinking of.
- FartyMcFarter 8y agoOn the contrary. For example, each python thread you create results in the creation of a POSIX thread in the interpreter, when you're running CPython on Linux. The GIL just means that only one of those threads will be executing pure-Python code at any time. But they're still normal threads.
- FartyMcFarter 8y agoIf you want to details about the GIL and Python threads, this is a nice presentation: http://www.dabeaz.com/python/UnderstandingGIL.pdf http://www.dabeaz.com/python/UnderstandingGIL.pdf