Dead-simple parallel data processing for Python
Project description
parlane
Dead-simple parallel data processing for Python.
parlane gives you parallel map, filter, and for-each in one line.
On GIL-free Python (3.13t+), it uses threads automatically.
On standard Python, it falls back to processes. You don't need to think about it.
from parlane import pmap
results = pmap(process, items) # That's it.
Why parlane?
| parlane | joblib | concurrent.futures | |
|---|---|---|---|
| Lines of code | 1 | 1 (but 3 concepts) | 3-4 |
| GIL-aware | Auto | No | No |
| Dependencies | Zero | numpy, etc. | stdlib |
| Type hints | Full (py.typed) | Partial | Partial |
Install
pip install parlane
Requires Python 3.10+. Zero dependencies.
Quick Start
from parlane import pmap, pfilter, pfor
# Parallel map
results = pmap(lambda x: x ** 2, range(1000))
# Parallel filter
evens = pfilter(lambda x: x % 2 == 0, range(1000))
# Parallel for-each (side effects)
pfor(save_to_db, records)
# With options
results = pmap(fetch, urls, workers=16, backend="thread", timeout=30.0)
API
pmap(fn, items, **options) -> list
Apply fn to each item in parallel. Returns results in order.
results = pmap(process_image, images)
pfilter(fn, items, **options) -> list
Keep items where fn returns True. Parallel evaluation.
valid = pfilter(is_valid, records)
pfor(fn, items, **options) -> None
Apply fn to each item for side effects.
pfor(send_notification, users)
pstarmap(fn, items, **options) -> list
Like pmap, but unpacks each item as arguments.
results = pstarmap(pow, [(2, 10), (3, 5), (10, 3)])
# [1024, 243, 1000]
Options
| Parameter | Type | Default | Description |
|---|---|---|---|
workers |
int |
CPU count | Number of parallel workers |
backend |
str |
"auto" |
"auto", "thread", or "process" |
timeout |
float |
None |
Per-task timeout in seconds |
chunksize |
int |
None |
Chunk size (process backend) |
on_error |
str |
"raise" |
"raise", "skip", or "collect" |
Error Handling
# Default: raise on first error
pmap(risky_fn, items) # raises immediately
# Skip errors silently
results = pmap(risky_fn, items, on_error="skip")
# Collect all results (Ok/Err)
results = pmap(risky_fn, items, on_error="collect")
for r in results:
if r.is_ok():
print(r.unwrap())
else:
print(f"Error: {r.exception}")
GIL Detection
from parlane import is_gil_disabled, recommended_backend
print(is_gil_disabled()) # True on 3.13t+, False otherwise
print(recommended_backend()) # "thread" or "process"
How It Works
- Detect GIL state at import time (cached)
- Choose backend automatically:
- GIL disabled ->
ThreadPoolExecutor(true parallelism, no serialization overhead) - GIL enabled ->
ProcessPoolExecutor(bypass GIL via multiprocessing)
- GIL disabled ->
- Execute with the chosen backend
- Return results in input order
Users can override with backend="thread" or backend="process".
Development
git clone https://github.com/owl-tech-sui/parlane
cd parlane
pip install -e ".[dev]"
# Run tests
pytest -v
# Lint
ruff check src/ tests/
ruff format --check src/ tests/
# Type check
mypy src/parlane/ --strict
License
MIT
Project details
Release history Release notifications | RSS feed
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 parlane-0.1.0.tar.gz.
File metadata
- Download URL: parlane-0.1.0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
200f5f40af708b3a9b86fb400cc3fb0b37be8b2bf49a0d0f4f30c79544b0e6aa
|
|
| MD5 |
49c93a18eacc87c8f54ef30dd37bc272
|
|
| BLAKE2b-256 |
db73467c0c7aa13231b1424376e03dd5fe8229ddd599700f62b84b1171c67970
|
Provenance
The following attestation bundles were made for parlane-0.1.0.tar.gz:
Publisher:
release.yml on owl-tech-sui/parlane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
parlane-0.1.0.tar.gz -
Subject digest:
200f5f40af708b3a9b86fb400cc3fb0b37be8b2bf49a0d0f4f30c79544b0e6aa - Sigstore transparency entry: 926226618
- Sigstore integration time:
-
Permalink:
owl-tech-sui/parlane@6cdd2305e1fc8f54de2ee2b9710bba89ea3b2062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/owl-tech-sui
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6cdd2305e1fc8f54de2ee2b9710bba89ea3b2062 -
Trigger Event:
push
-
Statement type:
File details
Details for the file parlane-0.1.0-py3-none-any.whl.
File metadata
- Download URL: parlane-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f83f3b3f0a7b5371b70998758f64bbc43ecbf028659ea9dfcb14818c7b27bf5
|
|
| MD5 |
1e14898d596f83085eb1b6171336f2c3
|
|
| BLAKE2b-256 |
dc575c9972e0935ac904c4d7a2d4e5564a26c4e8e19d1a2e3fd39c9c37274736
|
Provenance
The following attestation bundles were made for parlane-0.1.0-py3-none-any.whl:
Publisher:
release.yml on owl-tech-sui/parlane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
parlane-0.1.0-py3-none-any.whl -
Subject digest:
9f83f3b3f0a7b5371b70998758f64bbc43ecbf028659ea9dfcb14818c7b27bf5 - Sigstore transparency entry: 926226635
- Sigstore integration time:
-
Permalink:
owl-tech-sui/parlane@6cdd2305e1fc8f54de2ee2b9710bba89ea3b2062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/owl-tech-sui
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6cdd2305e1fc8f54de2ee2b9710bba89ea3b2062 -
Trigger Event:
push
-
Statement type: