MPIRE - MultiProcessing Is Really Easy

2.10.2 · active · verified Fri Apr 10

MPIRE is a Python package that simplifies multiprocessing, offering a faster and more user-friendly alternative to the standard `multiprocessing` module. It provides an intuitive API with map-like functions, support for worker state, progress bars (via tqdm), worker insights, and efficient handling of shared objects. The library is actively maintained with regular updates and aims to make parallelizing CPU-bound tasks straightforward and performant.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mpire.WorkerPool` to parallelize a simple function across multiple processes. It initializes a pool with 4 workers and uses the `map` function, similar to Python's built-in `map` but executed in parallel.

import time
from mpire import WorkerPool

def my_function(x):
    time.sleep(0.01) # Simulate some work
    return x * 2

# Run with 4 worker processes
with WorkerPool(n_jobs=4) as pool:
    results = pool.map(my_function, range(100))
    print(f"Results: {results[:5]}...")

view raw JSON →