PQDM - Parallel TQDM
PQDM is a TQDM and concurrent futures wrapper designed to provide enjoyable parallelization of iterating through an Iterable with a progress bar. It supports both process-based and thread-based parallel execution and automatically integrates with `tqdm.notebook` in Jupyter environments. The current version is 0.2.0, with the last PyPI release in February 2022, suggesting a mature or slower development cadence.
Warnings
- gotcha Choosing the correct backend (processes vs. threads) is crucial for optimal performance. Use `from pqdm.processes import pqdm` for CPU-bound tasks and `from pqdm.threads import pqdm` for I/O-bound tasks. Incorrect selection can lead to suboptimal performance, e.g., using threads for CPU-bound tasks in Python due to the GIL.
- gotcha When passing arguments to the target function, `pqdm` defaults to passing iterable elements directly. For functions expecting multiple positional arguments or keyword arguments, you must specify the `argument_type` parameter (e.g., `'args'` for `func(a, b)` with iterable `[[a1, b1], [a2, b2]]` or `'kwargs'` for `func(a=x, b=y)` with iterable `[{'a': x1, 'b': y1}, {'a': x2, 'b': y2}]`).
- gotcha The latest PyPI release (v0.2.0) for `pqdm` was in February 2022. While the library is functional, this suggests a slower or potentially maintenance-focused development cycle. Users seeking actively developed or frequently updated features might want to check the GitHub repository directly for the latest commits or consider alternative libraries if frequent updates are a requirement.
Install
-
pip install pqdm
Imports
- pqdm
from pqdm.processes import pqdm
Quickstart
from pqdm.processes import pqdm
import time
def long_running_task(number):
time.sleep(0.1) # Simulate work
return number * number
items = list(range(1, 101))
# Parallelize the task with 4 processes and a progress bar
results = pqdm(items, long_running_task, n_jobs=4, desc="Processing numbers")
print(f"First 5 results: {results[:5]}")