Skip to main content

lightstream

Move Arrow tables between processes, services and storage from Python without adding a gRPC stack or writing transport-specific framing.

lightstream provides one streaming API across files, memory maps, sockets and network transports. Readers return minarrow objects and implement the Arrow PyCapsule protocol, allowing PyArrow, Polars, DuckDB and other Arrow-compatible libraries to consume data straight off the wire without an intermediate conversion.

Installation

pip install lightstream-io

Unix-domain sockets and memory-mapped reads are available on Linux and macOS. Windows uses buffered file reads; uds:// and explicit mmap=True requests are unsupported.

Usage

Everything is read or write.

The URI selects the transport, protocol selects the wire framing, and file extensions select the storage format.

import lightstream as ls

Files

Read Arrow IPC, Parquet, CSV and JSON through the same interface.

# Read an entire dataset.
table = ls.read("quotes.arrow").read_all()

# Stream batches without loading the complete dataset into memory.
for batch in ls.read("large.parquet"):
    process(batch)

# Write any Arrow-compatible object.
with ls.write("output.parquet", compression="zstd") as writer:
    writer.write(table)

Arrow IPC readers use memory mapping and out-of-core routing where appropriate.

Readers yield minarrow.Table batches. read_all() returns a Table when the result is contiguous or a ChunkedTable when multiple chunks must be preserved.

Network transports

The same interface streams raw Arrow IPC over TCP, Unix domain sockets, WebSocket, HTTP, QUIC, WebTransport and standard I/O.

for batch in ls.read("tcp://feed.example.com:9000"):
    process(batch)

Supported URI schemes include:

Transport URI
TCP tcp://host:port
Unix domain socket uds:///path/to/socket
WebSocket ws://host/path
Secure WebSocket wss://host/path
HTTP http://host/path
HTTPS https://host/path
QUIC quic://host:port
WebTransport wt://host/path
Standard input/output stdio://

Accepting connections

Either endpoint can accept the connection.

Set accept=True to bind the endpoint on first use and block until the connecting peer arrives.

writer = ls.write(
    "uds:///tmp/feed.sock",
    accept=True,
)

writer.write(table)
writer.close()

The listener remains available for the lifetime of the process. Connections arriving while a serving loop is active wait in the listener backlog, allowing the accepting endpoint to operate as a persistent server.

TLS

QUIC and WebTransport include TLS at the protocol level. The accepting endpoint presents a PEM certificate and private key, while the connecting endpoint verifies the certificate using PEM roots.

writer = ls.write(
    "quic://0.0.0.0:4433",
    accept=True,
    tls_cert="server.pem",
    tls_key="server-key.pem",
)

for batch in ls.read(
    "quic://feed.example.com:4433",
    tls_ca="roots.pem",
):
    process(batch)

Secure WebSocket and HTTPS transports use their corresponding TLS-enabled URI schemes.

Arrow interoperability

Every reader implements the Arrow PyCapsule stream protocol.

Arrow-compatible libraries can therefore consume a Lightstream reader directly.

import duckdb
import lightstream as ls

reader = ls.read("quotes.arrow")

result = duckdb.sql(
    "SELECT SUM(qty) FROM reader"
)

The same reader can be passed to libraries such as Polars without first converting its batches into Python objects.

Lightstream protocol

The Lightstream protocol multiplexes named Arrow tables and opaque messages over one connection.

Opaque payloads can carry formats such as Protobuf or MessagePack, while table channels retain their Arrow schema and batch representation.

reader = ls.read(
    "uds:///tmp/feed.sock",
    protocol="lightstream",
)

reader.register_table(
    "quotes",
    representative_table,
)
reader.register_message("health")

for frame in reader:
    if frame.is_table():
        on_quotes(frame.table)
    else:
        on_health(frame.payload)

frame.table is a minarrow.Table. Message payloads are returned as bytes.

Both peers must register compatible channels before exchanging frames.

The protocol is transport-independent, so the same table and message definitions can be used over TCP, Unix domain sockets, WebSocket, HTTP, QUIC or WebTransport.

Standard I/O pipelines

The standard I/O transport can stream Arrow IPC or line-oriented text.

Set format="csv" to write CSV records or format="json" to write NDJSON. Text emitted by another process is decoded back into table batches on read.

This allows Unix tools, command-line programs and agents to participate directly in a table pipeline.

python examples/run-example.py sed
python examples/run-example.py jq
python examples/run-example.py claude
python examples/run-example.py sql

The pipeline examples demonstrate:

  • sed rewriting rows in flight
  • jq filtering NDJSON and returning CSV
  • an agent diagnosing invalid batches
  • rolling DuckDB SQL over a live stream

Transport examples

Worked examples are provided under examples/transport/.

Each transport includes:

  • a Python server
  • a Rust server
  • a Python client
  • the same million-row input table

Use the example router to select the transport and backend:

# Python backend over TCP.
python examples/run-example.py tcp

# Rust backend over QUIC.
python examples/run-example.py quic --rust

Available transports are:

tcp
uds
ws
wss
http
https
quic
wt
stdio

TLS examples generate a private root certificate and a server certificate for local execution.

Building from source

Lightstream currently requires the Rust nightly toolchain. The repository selects the required toolchain automatically through rust-toolchain.toml.

pip install maturin
maturin develop
pytest tests/

Licence

Copyright © 2025–2026 Peter Garfield Bower.

Licensed under the Mozilla Public License 2.0. See LICENSE for the standard terms.

See MPL 2.0 FAQ if you are unfamiliar with this open-source license.

Affiliation notice

Lightstream is not affiliated with Apache Arrow or the Apache Software Foundation.

It implements public Arrow formats through Minarrow and interoperates with the Arrow ecosystem through the Arrow PyCapsule protocol.

lightstream is maintained by SpaceCell and forms part of its open-source foundation for high-performance data computing.

Release files for lightstream-io 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lightstream-io 0.7.0
File Size Uploaded
lightstream_io-0.7.0.tar.gz 608.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for lightstream-io 0.7.0
File
lightstream_io-0.7.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
lightstream_io-0.7.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
lightstream_io-0.7.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
lightstream_io-0.7.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
lightstream_io-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 17.3 MB

Release files / lightstream_io-0.7.0.tar.gz

Download URL lightstream_io-0.7.0.tar.gz
Size 608.5 kB
Tags Source
SHA-256 checksum
How to use checksums
30f16416e05500b4c504c2975f78ead12100fa66196bc2656002bf395642118f
BLAKE2b-256 checksum
How to use checksums
78e6957523d33156e3cc9666f87516df6dac729bf2e218a98e966583017a131c
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 Sep 19, 2026.

Transparency log

Release files / lightstream_io-0.7.0-cp39-abi3-win_amd64.whl

Download URL lightstream_io-0.7.0-cp39-abi3-win_amd64.whl
Size 3.4 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5d69c25c50939fa38b84475ab04915e99dd0511cd464836a11674ca1fd205da8
BLAKE2b-256 checksum
How to use checksums
38b894dd0714fd813453945c49b818934d9ff8ed56754f8da5c46cf87ec96e51
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 Sep 19, 2026.

Transparency log

Release files / lightstream_io-0.7.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lightstream_io-0.7.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.5 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3f04f5289286fd2014c2a48cc56323e5364dd4ce51a38fbf6b6947b02a7e50f1
BLAKE2b-256 checksum
How to use checksums
9b7e307094d910895cd64b3db82f7d3f7fa7b18b489cbd580daa020a55835d37
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 Sep 19, 2026.

Transparency log

Release files / lightstream_io-0.7.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL lightstream_io-0.7.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.3 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
9894573332540dfcb4b0b99377d2041a4a58154a813d5de206d7df9eb3cc141f
BLAKE2b-256 checksum
How to use checksums
86f650eaa080135ec07db711cad30b9799ed58d98ee373b0bc3416db92380cfe
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 Sep 19, 2026.

Transparency log

Release files / lightstream_io-0.7.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL lightstream_io-0.7.0-cp39-abi3-macosx_11_0_arm64.whl
Size 3.1 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bd0b2f11094355149fccd693610622ab6da64674da2903b2dfe2d724f986fe7f
BLAKE2b-256 checksum
How to use checksums
d0696accfbf26de4e37f4bae10949e7c6ee97983abc53580571d75aff5b28af8
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 Sep 19, 2026.

Transparency log

Release files / lightstream_io-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL lightstream_io-0.7.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 3.3 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
52844542a71e99bce475fefa6da432b7a8cbd0b4d4b52e85fce5bffd13db18f1
BLAKE2b-256 checksum
How to use checksums
98be8ef6658de7f0b56b5773c328f575c493bead7b2ba9b1fa95dd03e297ea71
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 Sep 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.0 This release

6 release files

0.6.0

5 release files

0.5.0

5 release 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