Although python supports both [1] and [2] models the support for threads has a following warning:
[1] CPython implementation detail: Due to the Global Interpreter Lock, in CPython only one thread can execute Python code at once.
It took me a while to understand what this actualy means. This is a serious limitation for a multithreaded programming and it still exists even in the latest python version 3.x [3]. To better understanding what this means this is an example from one of the links below I found:
The GIL enforces Python's requirement that only a single bytecode operation is executed at a time.
References
- http://docs.python.org/library/threading.html
- http://docs.python.org/library/multiprocessing.html#module-multiprocessing
- http://docs.python.org/py3k/library/threading.html
- Google search about GIL has many link, I personaly found these very useful http://www.grouplens.org/node/244
- These below are a little longer to read but they talk about the problem and around it on a very low level http://www.jeffknupp.com/blog/2012/03/31/pythons-hardest-problem/
http://linuxgazette.net/107/pai.html
The section "Write multithreaded or multiprocess code"
http://www.scipy.org/ParallelProgramming
http://stackoverflow.com/questions/10344529/is-the-max-thread-limit-actually-a-non-relevant-issue-for-python-linux
http://stackoverflow.com/questions/7053284/what-is-more-suitable-in-performance-aspect-multithreading-or-multiprocessing
http://jessenoller.com/2009/02/01/python-threads-and-the-global-interpreter-lock/
No comments:
Post a Comment