This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
"Threads do indeed exist in Python but should be avoided where possible.
This has nothing to do with the quality of Python’s threading library and
everything to do with Python’s implementation, especially the implementation
known as CPython (which is more than likely the one you’re running
now). Python is implemented using a technology known as the Global
Interpreter Lock (GIL), which enforces a restriction that Python can only
ever run on a single interpreter process, even in the presence of multiple
processors. What all this means to you is that your beautifully designed and implemented
program that uses threads will never run faster on multiple processors even
if they exist, because it can’t use them. Your threaded application will run
serially and, in many cases, run considerably slower than if you had developed
the same functionality without resorting to threads.
Main message: don’t use threads with Python until the GIL restriction is
removed…if it ever is."
Does that mean that usually one uses threading in python only when the application has both IO-Bound and CPU-Bound activities?
For CPython, yes. But if you are using a different implementation of Python, it may have a different threading system which makes full multi-threaded applications possible. For example Jython uses Java's underlying threading library, and IronPython uses .NET's threading library, making them both implementations that are not limited by the GIL.