On 18 Aug, 11:41, Stefan Behnel <stefan...@behnel.de> wrote: > I think the canonical answer is to use the threading module or (preferably) > the multiprocessing module, which is new in Py2.6. > > http://docs.python.org/library/threading.htmlhttp://docs.python.org/library/multiprocessing.html > > Both share a (mostly) common interface and are simple enough to use. They > are pretty close to the above interface already.
There is a big difference between them, which is that multiprocessing do not work with closures. This means that the threading module is simpler to use than multiprocessing if you want to parallelize serial code. You just wrap a closure around whatever block of code you want to run in a thread. For the same reason, programming with OpenMP is easier than using pthreads directly in C/C++. C does not have closures, which is the raison d'etre for OpenMP. Multiprocessing has the same limitation as abstraction for parallel programming as pthreads in C. Python's threading module do not, but the GIL can be a limitation. -- http://mail.python.org/mailman/listinfo/python-list