Skip to main content

Parallel map with a built-in terminal progress bar

Project description

philiprehberger-progress-map

Tests PyPI version License

Parallel map with a built-in terminal progress bar.

Install

pip install philiprehberger-progress-map

Usage

from philiprehberger_progress_map import pmap

def process(x):
    return x * 2

results = pmap(process, range(100))

Use multiprocessing instead of threading:

results = pmap(process, range(100), mp=True, workers=8)

Customize the progress display:

results = pmap(process, items, label="Processing", show_progress=True)

API

pmap(func, items, *, workers=4, mp=False, label="", show_progress=True)

Parameter Type Default Description
func Callable[[T], R] Function to apply to each item
items Iterable[T] Iterable of items to process
workers int 4 Number of worker threads or processes
mp bool False Use multiprocessing instead of threading
label str "" Optional label prefix for the progress bar
show_progress bool True Whether to display the progress bar

Returns: list[R] — Results in the same order as the input items.

Development

pip install -e .
python -m pytest tests/ -v

License

MIT

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

philiprehberger_progress_map-0.1.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

philiprehberger_progress_map-0.1.3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_progress_map-0.1.3.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_progress_map-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ef2a22cffc083a04d64f150751629c2f236bcd2cfbeb1c2193b4ce3019cea43f
MD5 e9d8e61b113d8c6ef0a42f0272ec96e7
BLAKE2b-256 d9f306164afc2556d44609afebbb845b9f1ce4a039f19b4073c3602fec4358f9

See more details on using hashes here.

File details

Details for the file philiprehberger_progress_map-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_progress_map-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0399f9c93c97143ef90bb625cc967b1c1203ab48bf9d7a3b5520945962ff0537
MD5 a1e79893339ebdd879cb2f64a2720e22
BLAKE2b-256 ff13672bfd94d389aabffdac1d800439defd7a81edda11aac5ea87959fa1ee64

See more details on using hashes here.

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