Parallel map with a built-in terminal progress bar
Project description
philiprehberger-progress-map
Parallel map with a built-in terminal progress bar.
Installation
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_progress_map-0.1.5.tar.gz.
File metadata
- Download URL: philiprehberger_progress_map-0.1.5.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2aa5fefb16f0059715149243cafd226fe2930d44ca3a71d6be41050fe9ed239
|
|
| MD5 |
bbd98b8a90dee93502b3ed2ae87979c3
|
|
| BLAKE2b-256 |
7279542f58b8dccaab611e44a24d290cd4bc79d5b891dc02bba58fa22733a41b
|
File details
Details for the file philiprehberger_progress_map-0.1.5-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_progress_map-0.1.5-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec7ef4236210759b3eb6f401008b2a9c129e4860b705dd876bc70623f5e31bb0
|
|
| MD5 |
f51a16c192afcb5bf33bb4f6e5450b0b
|
|
| BLAKE2b-256 |
19d417670e1cbdbe33a0ca5110260a15379ca99896d017c162eb7dc3e1ac2336
|