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.

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.1.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.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_progress_map-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8dcf446b5fe0be435cecb6879f5aaa9d2fb5d401812ef9d65c5f09b39215f33f
MD5 3c9df7d09e97255376bb473a07cb20e4
BLAKE2b-256 0aaf243e78dfba00a12b41338875a50d2d72bc49cb410266294897e53f080104

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_progress_map-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 20321367d2e3bad11c62bc3c7216831d6594fea29d7b09fe96acade2c00c193b
MD5 30f63740ad9d9e9d39676a51fa4bba1e
BLAKE2b-256 a3f0685075ea191c675e71640a5db1acbaa5c9160d5a66d31fd5f1c416d923d2

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