batch_please
A flexible and efficient Python library for processing large datasets in batches, with support for both synchronous and asynchronous operations.
Features
- Process large datasets in customizable batch sizes
- Support for both synchronous and asynchronous processing
- Flexible input handling - accepts iterables or dictionaries of keyword arguments
- Checkpoint functionality to resume processing from where it left off
- Optional progress bar using tqdm
- Configurable concurrency limit for asynchronous processing
- Logging support
Installation
pip install batch_please
Quick Start
Synchronous Processing
from batch_please import BatchProcessor
# Simple iterable input
def process_func(item):
return f"Processed: {item}"
processor = BatchProcessor(
process_func=process_func,
batch_size=100,
use_tqdm=True
)
input_data = range(1000)
processed_items = processor.process_items_in_batches(input_data)
# Dictionary input with keyword arguments
def process_with_params(name, value):
return f"{name}: {value}"
processor = BatchProcessor(
process_func=process_with_params,
batch_size=100,
use_tqdm=True
)
input_data_dict = {
f"item_{i}": {"name": f"Item {i}", "value": i * 10}
for i in range(100)
}
processed_items = processor.process_items_in_batches(input_data_dict)
Asynchronous Processing
import asyncio
from batch_please import AsyncBatchProcessor
# Simple iterable input
async def async_process_func(item):
await asyncio.sleep(0.1)
return f"Processed: {item}"
async def main():
processor = AsyncBatchProcessor(
process_func=async_process_func,
batch_size=100,
max_concurrent=10,
use_tqdm=True
)
input_data = range(1000)
processed_items = await processor.process_items_in_batches(input_data)
# Dictionary input with keyword arguments
async def process_with_params(name, value):
await asyncio.sleep(0.1)
return f"{name}: {value}"
processor = AsyncBatchProcessor(
process_func=process_with_params,
batch_size=100,
max_concurrent=10,
use_tqdm=True
)
input_data_dict = {
f"item_{i}": {"name": f"Item {i}", "value": i * 10}
for i in range(100)
}
processed_items = await processor.process_items_in_batches(input_data_dict)
asyncio.run(main())
Advanced Usage
Checkpoint Recovery
processor = BatchProcessor(
process_func=process_func,
batch_size=100,
pickle_file="checkpoint.pkl",
recover_from_checkpoint=True
)
Logging
processor = BatchProcessor(
process_func=process_func,
batch_size=100,
logfile="processing.log"
)
Further Documentation
Release files for batch-please 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| batch_please-0.3.1.tar.gz | 63.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| batch_please-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 70.6 kB
Release files / batch_please-0.3.1.tar.gz
| Download URL | batch_please-0.3.1.tar.gz |
|---|---|
| Size | 63.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98beb3262c6df6a0e1f4c0c1d4e9eaf9d9bf98b4a06340db9ddfeecdd412c771
|
|
BLAKE2b-256 checksum How to use checksums |
b0678d664f06d31a5cc52b1ce567af9755d1e094b8f4fcf14edcfeb9e7d5e8eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2025.
Transparency logRelease files / batch_please-0.3.1-py3-none-any.whl
| Download URL | batch_please-0.3.1-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe0a517b5b50ab4f1395f83d5fdff7f10698d9bde3cda924e78130a6c4dfd9f1
|
|
BLAKE2b-256 checksum How to use checksums |
a4b09e931530655562b1126df43701f5fd8893cf500dde387960e2e0766356b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2025.
Transparency log