using threads with for-loops

Peter Hansen peter at
Tue Sep 28 17:16:03 EDT 2004

Mathias Waack wrote:
> I haven't seen such implementation and don't know much
> about the thread-layer of Python. 

Unfortunately, there is something called the Global
Interpreter Lock (GIL), which means that even though
native threads are (generally) used for Python threads,
only one of those threads can be active in the interpreter
at any time, even if there are multiple CPUs present.

> Depends. Which means: don't know. If I would start thinking about
> creating threads to gain a speedup, I would even think about
> switching to another programming language. 

I believe some work has been done in this area to make
Python take advantage of multiple CPU systems, but
I believe your approach (switch languages) is still one of
the best options.  Another is to arrange your application
to run as multiple processes, but this isn't quite as
simple as just using multiple threads.


More information about the Python-list mailing list