Both list comprehensions and map-calculations should -- at least in theory -- be relatively easy to parallelize: each calculation inside a list-comprehension could be done independent of the calculation of all the other elements. For example in the expression
[ x*x for x in range(1000) ]
each x*x-Calculation could (at least in theory) be done in parallel.
My question is: Is there any Python-Module / Python-Implementation / Python Programming-Trick to parallelize a list-comprehension calculation (in order to use all 16 / 32 / ... cores or distribute the calculation over a Computer-Grid or over a Cloud)?
Using the
futures.{Thread,Process}PoolExecutor.map(func, *iterables, timeout=None)
andfutures.as_completed(future_instances, timeout=None)
functions from the new 3.2 concurrent.futures package could help.It's also available as a 2.6+ backport.