fpstreams
Typed, lazy data pipelines for Python, with synchronous streams, structured asynchronous concurrency, record-oriented transforms, and optional Rust execution.
fpstreams 2 is the stable, ground-up replacement for the v1 implementation.
What is in v2
Flow[T]: lazy, reiterable or one-shot synchronous pipelines.AsyncFlow[T]: asynchronous transforms with bounded concurrency, ordering, timeouts, merging, debouncing, and cancellation-safe cleanup.Rows[T]: expressions, joins, grouping, reshape operations, CSV/JSONL/SQL, Arrow, Parquet, pandas, and Polars interoperability.Pairs[K, V]: key/value transforms and per-key collection or aggregation.CollectorandAggregator: single-pass reductions, including named multi-aggregation.OptionandResult: typed value and error containers.- Automatic execution planning: fused Python loops, native Rust kernels for supported numeric plans, and hybrid execution when only part of a plan is native.
- Bounded-memory operations such as external sort and partitioned joins/grouping.
Python 3.11 or newer is required.
Installation
Install the latest stable release:
pip install fpstreams
Install optional integrations only when needed:
pip install "fpstreams[async]" # aiofiles
pip install "fpstreams[arrow]" # PyArrow and Parquet
pip install "fpstreams[data]" # NumPy, pandas, and PyArrow
pip install "fpstreams[polars]" # Polars and PyArrow
Quick start
Pipelines are lazy. Transformations build a plan; terminal operations such as
to_list(), aggregate(), first(), and count() execute it.
from fpstreams import flow, item
squares = (
flow(range(1, 10))
.filter(item % 2 == 0) # Keep even values.
.map(item * item) # Square each value.
.take(3) # Stop after three results.
.to_list()
)
assert squares == [4, 16, 36]
The placeholder expression above is equivalent to two lambdas, but it can also be compiled by the native engine when the complete plan is supported.
Named single-pass aggregation
from fpstreams import agg, flow
summary = flow([1, 2, 3, 4]).aggregate(
count=agg.count(),
total=agg.sum(),
mean=agg.mean(),
)
assert summary == {"count": 4, "total": 10, "mean": 2.5}
All named aggregations share one traversal of the source.
Record pipelines
Rows accepts dictionaries, dataclasses, named tuples, and objects with attributes.
from fpstreams import agg, col, rows
orders = [
{"region": "eu", "status": "paid", "price": 12, "quantity": 2},
{"region": "us", "status": "paid", "price": 20, "quantity": 1},
{"region": "eu", "status": "cancelled", "price": 99, "quantity": 1},
{"region": "eu", "status": "paid", "price": 8, "quantity": 3},
]
revenue = (
rows(orders)
.where(col("status") == "paid")
.with_columns(revenue=col("price") * col("quantity"))
.group_by("region")
.aggregate(
orders=agg.count(),
revenue=agg.sum("revenue"),
)
.sort_by("region")
.to_list()
)
assert revenue == [
{"region": "eu", "orders": 2, "revenue": 48},
{"region": "us", "orders": 1, "revenue": 20},
]
Rows also reads and writes Arrow, Parquet, pandas, Polars, SQLite, and
DB-API sources:
from fpstreams import col, rows
active = (
rows.from_parquet("accounts.parquet", columns=["id", "status", "balance"])
.where(col("status") == "active")
.select("id", "balance")
)
active.to_parquet("active-accounts.parquet")
Asynchronous pipelines
map_async accepts synchronous or asynchronous callables. concurrency bounds
in-flight tasks, while ordered=True preserves input order.
import asyncio
from fpstreams import aflow
async def fetch(value: int) -> int:
await asyncio.sleep(0.01)
return value * 10
async def main() -> None:
result = await (
aflow([1, 2, 3, 4])
.map_async(fetch, concurrency=2, ordered=True)
.filter(lambda value: value >= 20)
.to_list()
)
assert result == [20, 30, 40]
asyncio.run(main())
Async iterators and outstanding tasks are closed or cancelled when a pipeline finishes, errors, times out, or short-circuits.
Key/value pipelines
from fpstreams import agg, pairs
totals = pairs([("a", 2), ("b", 5), ("a", 3)]).aggregate_values(
total=agg.sum(),
average=agg.mean(),
)
assert totals == {
"a": {"total": 5, "average": 2.5},
"b": {"total": 5, "average": 5.0},
}
Execution engines
The default auto engine chooses between Python, native Rust, and hybrid execution.
Use explain() before execution to inspect that decision:
from fpstreams import flow, item
pipeline = flow([1, 2, 3]).map(item + 1).filter(item > 2)
plan = pipeline.explain().to_dict()
assert plan["selected_engine"] == "python"
assert plan["stages"][0]["fused"] is True
You can request an engine explicitly when testing parity or diagnosing a plan:
python_result = pipeline.with_engine("python").to_list()
native_result = pipeline.with_engine("native").to_list()
A forced native plan raises NativeUnsupportedError if its types or operations
cannot run natively. auto falls back safely.
For data larger than memory, use external_sort(..., buffer_size=...),
Rows.join(..., partitions=...), or Rows.group_by(...).spill(...) instead of
materializing the entire input.
Source and resource semantics
- Reiterable inputs such as lists can execute more than once.
- Iterators and async iterators are one-shot and raise
FlowConsumedErroron a second execution. flow.defer(factory)opens a fresh source for every execution.- Terminal operations close owned iterators, database cursors, temporary files, and asynchronous tasks, including on errors and early termination.
v1 compatibility
Stream remains an alias of Flow, AsyncStream remains an alias of
AsyncFlow, and ParallelStream remains an alias of Flow to ease imports.
New v2 code should use flow, aflow, rows, and pairs directly.
v2 breaks parts of the v1 API. The standalone core and ParallelStream
implementations are gone. ParallelStream remains an alias, and Flow.parallel()
remains as a compatibility strategy for following maps. New code can call
parallel_map() directly or use map_async() for asynchronous work.
Development
uv sync --extra arrow --extra data --extra polars \
--group build --group test --group lint --group type --group docs
uv run pytest
uv run ruff check .
uv run mypy
cargo test --manifest-path rust/Cargo.toml
uv run mkdocs build --strict -f fpstreams/mkdocs.yml
The source tree is organized by domain under src/fpstreams/: streams,
planning, execution, collecting, tabular, expressions, and primitives.
Small top-level modules are compatibility facades, not duplicate implementations.
License
MIT. See LICENSE.
Release files for fpstreams 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fpstreams-2.0.0.tar.gz | 96.6 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| fpstreams-2.0.0-cp311-abi3-win_arm64.whl | CPython 3.11 | abi3 | Windows ARM64 | Details |
| fpstreams-2.0.0-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| fpstreams-2.0.0-cp311-abi3-musllinux_1_2_x86_64.whl | CPython 3.11 | abi3 | Linux musl 1.2+ x86-64 | Details |
| fpstreams-2.0.0-cp311-abi3-musllinux_1_2_aarch64.whl | CPython 3.11 | abi3 | Linux musl 1.2+ ARM64 | Details |
| fpstreams-2.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| fpstreams-2.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| fpstreams-2.0.0-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
| fpstreams-2.0.0-cp311-abi3-macosx_10_12_x86_64.whl | CPython 3.11 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 3.3 MB
Release files / fpstreams-2.0.0.tar.gz
| Download URL | fpstreams-2.0.0.tar.gz |
|---|---|
| Size | 96.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d3aacfe9042ef9bc7675552ce7a21ca5358a3028a1fbb94e66cbc7e115c8c59
|
|
BLAKE2b-256 checksum How to use checksums |
f83e4bc6a43f77697071f80d2829298844e0b18a7a2583dbd03e1ad73e37206d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 14, 2026.
Transparency logRelease files / fpstreams-2.0.0-cp311-abi3-win_arm64.whl
| Download URL | fpstreams-2.0.0-cp311-abi3-win_arm64.whl |
|---|---|
| Size | 251.9 kB |
| Tags | CPython 3.11 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
2fcedf433e3053dd2fedcd96dd20db0bebc8c91508a37899d0911e3a66d6b615
|
|
BLAKE2b-256 checksum How to use checksums |
3f25b92f03a39c552b6e02899eb2bb1e89f7645ba2d03bf7e0cc0b83b6b80a69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 14, 2026.
Transparency logRelease files / fpstreams-2.0.0-cp311-abi3-win_amd64.whl
| Download URL | fpstreams-2.0.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 258.1 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
39e31fa9cd120c4a28bd7b25f1097ef1e89292a90c0b9f21ee5bafed71f3b4f0
|
|
BLAKE2b-256 checksum How to use checksums |
97d0955197f7b3eb06e3046025122b38a3660d278e51ce441bb9c0bc56e394da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 14, 2026.
Transparency logRelease files / fpstreams-2.0.0-cp311-abi3-musllinux_1_2_x86_64.whl
| Download URL | fpstreams-2.0.0-cp311-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 602.7 kB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
00100afac7591fa76a304f61ff800aaa4e571d721c1919988ec938aa35698945
|
|
BLAKE2b-256 checksum How to use checksums |
738148f72c470754776c0fabdc92c1e9aef8728a5fede26670192f74cbedeb99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 14, 2026.
Transparency logRelease files / fpstreams-2.0.0-cp311-abi3-musllinux_1_2_aarch64.whl
| Download URL | fpstreams-2.0.0-cp311-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 570.0 kB |
| Tags | CPython 3.11 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f410a7fdf80f8e641611ca99de763d2977da3ad52a13db9f7918d8a64180136b
|
|
BLAKE2b-256 checksum How to use checksums |
27ac53cef97502a136cb4ccd94731fc3dc819ba19fb7f2f104c395e0d7412b5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 14, 2026.
Transparency logRelease files / fpstreams-2.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | fpstreams-2.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 398.9 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5128301179e89872c6c9208ad6dd96ad09057ca7e8732c1b28d33d2115c156c6
|
|
BLAKE2b-256 checksum How to use checksums |
fd1ef447e91a6469ffe8eef399a8480a8998c46b766d626a8a93e52357710304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 14, 2026.
Transparency logRelease files / fpstreams-2.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | fpstreams-2.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 393.1 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ea28c80128879fee457e775d5b9f81fe5cb097648e145e0d639b6913a0e41a7c
|
|
BLAKE2b-256 checksum How to use checksums |
c89d8747b49050fdd05aef32c29c9702fdf4159197d0eea4c4aae4b0ab08b914
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 14, 2026.
Transparency logRelease files / fpstreams-2.0.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | fpstreams-2.0.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 359.1 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3317e8115fc92f5d04039659f43589118dfc327d347ed8115b78e5f1ee068726
|
|
BLAKE2b-256 checksum How to use checksums |
1672ee161660db3700f76d6d43b8d821f7c699319c7e6e6c0fdf51d092bf6c50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 14, 2026.
Transparency logRelease files / fpstreams-2.0.0-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | fpstreams-2.0.0-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 363.7 kB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
905248257fbf404b915b0af7cb6f5dc3647d4c00137d716eb5820d87d45e4be7
|
|
BLAKE2b-256 checksum How to use checksums |
c510d2c3bad27663bacc96370aa50770922326096d7d1365cb6bfc096c8598c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 14, 2026.
Transparency log