Parallelization in Python 2.6

sturlamolden sturlamolden at
Wed Aug 19 15:31:20 CEST 2009

On 18 Aug, 11:41, Stefan Behnel <stefan... at> wrote:

> I think the canonical answer is to use the threading module or (preferably)
> the multiprocessing module, which is new in Py2.6.
> 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

More information about the Python-list mailing list