Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



On 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.


Ah, you are correct, it's the non-threadedness of the interpreter itself I was thinking of.


On 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.


If you want to details about the GIL and Python threads, this is a nice presentation:

http://www.dabeaz.com/python/UnderstandingGIL.pdf




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: