Skip to main content

Parallel map with an optional rich progress bar.

Project description

parvelo

A tiny utility for parallel map with a rich progress bar.

parvelo.parallel_map runs a function over an iterable using either a process pool (CPU-bound work) or a thread pool (I/O-bound work), preserves input order, and optionally renders a progress bar.

parallel_map progress bar

Install

Requires Python 3.13.

pip install parvelo

From source:

git clone https://github.com/h-ahl/parvelo.git
cd parvelo
uv sync --extra lint --group dev

Usage

import time

from parvelo import Backend, parallel_map


def square(x: int) -> int:
    return x * x


def fetch(url: str) -> str:
    time.sleep(0.05)  # stand-in for network I/O
    return url


# CPU-bound work across processes (default)
results = parallel_map(square, range(10))

# I/O-bound work across threads
urls = [f"https://example.com/{i}" for i in range(16)]
results = parallel_map(fetch, urls, backend=Backend.THREAD, n_workers=16)

# Run serially (handy for debugging), skipping executor overhead
results = parallel_map(square, range(10), n_workers=1)

Reusing or injecting your own executor

Pass an executor to reuse a caller-owned pool across calls instead of creating one each time. Any object with a concurrent.futures-style map(func, *iterables, chunksize=1) qualifies (matched by the ExecutorLike protocol), so a stdlib executor or a custom wrapper around a ray/jax pool both work. When executor is provided, backend, n_workers, and multiprocessing_context are ignored, and parvelo does not shut the executor down (you own its lifecycle).

from concurrent.futures import ProcessPoolExecutor

from parvelo import parallel_map


def square(x: int) -> int:
    return x * x


with ProcessPoolExecutor() as pool:
    a = parallel_map(square, range(10), executor=pool)
    b = parallel_map(square, range(10, 20), executor=pool)  # pool reused, not recreated

Development

just setup       # create the environment
just test        # run the test suite
just lint        # ruff check
just format      # ruff format
just typecheck   # ty check
just pre-commit  # run all pre-commit hooks

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parvelo-0.3.1.tar.gz (73.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parvelo-0.3.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file parvelo-0.3.1.tar.gz.

File metadata

  • Download URL: parvelo-0.3.1.tar.gz
  • Upload date:
  • Size: 73.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for parvelo-0.3.1.tar.gz
Algorithm Hash digest
SHA256 33d60921073b7e75e922392f4e58000996d2df1b2d7aaf9389eedd3912d47666
MD5 89a680cf3e85c59a5acf348af93e6859
BLAKE2b-256 e5f2201cb2130ad85f778a5af4d20d63fa01b2196613d5193b432b01270a1edb

See more details on using hashes here.

Provenance

The following attestation bundles were made for parvelo-0.3.1.tar.gz:

Publisher: release.yml on h-ahl/parvelo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parvelo-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: parvelo-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for parvelo-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e002b222f8eecf4123cc5ce47af2c005762320557db3678d01ce1b1681d89beb
MD5 75e409dc6839bc8845d7dcb4daf1f85a
BLAKE2b-256 e6b114546b6d24e7f79b727bd7d749aa23b33c3e789e0094af8c28b44dbc1cef

See more details on using hashes here.

Provenance

The following attestation bundles were made for parvelo-0.3.1-py3-none-any.whl:

Publisher: release.yml on h-ahl/parvelo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page