Skip to main content

larzpipe

Lazy, composable data pipelines. Pure Python, zero dependencies.

Instead of nesting map(filter(...)) inside out, or building intermediate lists, chain the operations left-to-right and evaluate lazily. Nothing runs until you ask for a result, so infinite and huge sources are fine.

from larzpipe import pipe

(pipe(range(1_000_000))
    .filter(lambda x: x % 2 == 0)
    .map(lambda x: x * x)
    .take(5)
    .to_list())                 # [0, 4, 16, 36, 64]

pipe(words).map(str.lower).distinct().group_by(len)

Why

  • Reads top-to-bottom. The order you write is the order data flows - no more reading map(filter(map(...))) from the inside out.
  • Lazy. Everything is generator-based; take(5) off an infinite source does five items of work. Re-iterable when the source is (lists, ranges).
  • Batteries. map filter flat_map take/skip take_while/drop_while distinct(key) batch window enumerate tap sort zip chain, plus terminals to_list/to_dict/reduce/group_by/count/first/sum/min/ max/any/all.
  • Zero dependencies. Just a friendly face over itertools.

Install

pip install larzpipe

Usage

from larzpipe import pipe

pipe(data).filter(pred).map(fn).batch(100).for_each(save)
pipe(logs).map(parse).distinct(key=lambda e: e.id).group_by(lambda e: e.level)
pipe(nums).take_while(lambda x: x < 100).reduce(lambda a, b: a + b)

Tests

python -m unittest discover -s tests -v   # 20 tests incl. laziness + re-iterability

The Larz stack

One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.

License

MIT (c) larz-scripter

Download files

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

Source Distribution

larzpipe-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

larzpipe-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file larzpipe-0.1.0.tar.gz.

File metadata

  • Download URL: larzpipe-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzpipe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 05246508d6e87e5903ed5ac202c7b608bffbf9167c27f9f35cdd5e44d1380167
MD5 abbce143534b3b78243f074f20b3f3dd
BLAKE2b-256 22bc1996e6b99c7e734cd601e1d984fe64147a5c37ee0eebb78e21f946ca7a99

See more details on using hashes here.

File details

Details for the file larzpipe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: larzpipe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzpipe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 691fe1b5efd122100992c6c1eba555dff1ecd9649ef17321568ec34977276f0f
MD5 744d1b652609d7c5abf03c4a6fa2f2a1
BLAKE2b-256 30bbfbf02ca1012bacd0f20685791f66e260dbb5ad866ba909cbea30a28323f6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page