Skip to main content

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

  1. Detect GIL state at import time (cached)
  2. Choose backend automatically:
    • GIL disabled -> ThreadPoolExecutor (true parallelism, no serialization overhead)
    • GIL enabled -> ProcessPoolExecutor (bypass GIL via multiprocessing)
  3. Execute with the chosen backend
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parlane-0.1.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parlane-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

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

Hashes for parlane-0.1.0.tar.gz
Algorithm Hash digest
SHA256 200f5f40af708b3a9b86fb400cc3fb0b37be8b2bf49a0d0f4f30c79544b0e6aa
MD5 49c93a18eacc87c8f54ef30dd37bc272
BLAKE2b-256 db73467c0c7aa13231b1424376e03dd5fe8229ddd599700f62b84b1171c67970

See more details on using hashes here.

Provenance

The following attestation bundles were made for parlane-0.1.0.tar.gz:

Publisher: release.yml on owl-tech-sui/parlane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for parlane-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f83f3b3f0a7b5371b70998758f64bbc43ecbf028659ea9dfcb14818c7b27bf5
MD5 1e14898d596f83085eb1b6171336f2c3
BLAKE2b-256 dc575c9972e0935ac904c4d7a2d4e5564a26c4e8e19d1a2e3fd39c9c37274736

See more details on using hashes here.

Provenance

The following attestation bundles were made for parlane-0.1.0-py3-none-any.whl:

Publisher: release.yml on owl-tech-sui/parlane

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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