Para
raw JSON → 0.0.8 verified Fri May 01 auth: no python
Para (v0.0.8) is a utility set that leverages Python's 'multiprocessing' module to distribute CPU-intensive tasks across multiple cores. It provides a simple API for parallel execution with built-in progress bar support and exception handling. Release cadence is irregular.
pip install para Common errors
error AttributeError: Can't pickle local object 'my_function.<locals>.<lambda>' ↓
cause Lambda functions cannot be pickled by multiprocessing.
fix
Use a named top-level function instead of lambda.
error TypeError: map() got an unexpected keyword argument 'nprocesses' ↓
cause The parameter is 'nprocesses' (note the uppercase 'P'), not 'nprocesses'.
fix
Use correct keyword: map(func, data, nprocesses=4).
Warnings
gotcha The library is very early stage (v0.0.8); API may change. Not recommended for production. ↓
fix Consider alternatives like concurrent.futures, multiprocessing.Pool, or joblib.
gotcha map returns a generator, not a list. You must consume it (e.g., list(results)) to execute the tasks. ↓
fix Wrap call with list() or iterate explicitly.
gotcha If the function is not picklable (e.g., lambda, nested function, class method), multiprocessing will raise an error. Use functools.partial or top-level functions. ↓
fix Define the function at module level or use pathos.multiprocessing instead.
Imports
- map
from para import map - map_unordered
from para import map_unordered - map_starmap
from para import map_starmap
Quickstart
from para import map
def square(x):
return x * x
results = map(square, range(10), nprocesses=4)
print(list(results))
# [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]