Skip to main content

Header

PyStreamAPI

DeepSource Tests Pylint Quality Gate Coverage PyPI - Downloads PyPI

PyStreamAPI is a Python stream library inspired by the Java Stream API, adding Pythonic features for clean, declarative, and efficient data processing. It supports both sequential and parallel streams with lazy evaluation.

from pystreamapi import Stream

Stream.of([" ", '3', None, "2", 1, ""]) \
    .filter(lambda x: x is not None) \
    .map(str) \
    .map(lambda x: x.strip()) \
    .filter(lambda x: len(x) > 0) \
    .map(int) \
    .sorted() \
    .for_each(print) # Output: 1 2 3

Installation

pip install streams.py
from pystreamapi import Stream

🎉 PyStreamAPI is now ready to process your data

Why PyStreamAPI?

  • Sequential and parallel streams out of the box
  • Lazy execution for efficient processing of large datasets
  • 100% test coverage
  • Pythonic API — clean, readable, and expressive
  • 111+ built-in conditions for filtering and matching
  • Declarative error handling with configurable error levels
  • Built-in loaders for CSV, JSON, XML, YAML and TOML files

Building a Stream

PyStreamAPI provides two stream types — Stream (general-purpose) and NumericStream (for numerical data with statistics) — each available in sequential and parallel flavors.

Stream.of([1, 2, 3])               # auto-selects sequential or numeric
Stream.parallel_of([1, 2, 3])      # parallel stream
Stream.sequential_of([1, 2, 3])    # sequential stream
Stream.of_noneable(None)           # returns empty stream when source is None
Stream.iterate(0, lambda n: n + 2) # infinite stream (use .limit())
Stream.concat(Stream.of([1, 2]), Stream.of([3, 4]))  # merge streams

For the full API reference see the docs.

Conditions

Conditions

Over 111 ready-to-use conditions across strings, numbers, types, and dates — combine them freely with one_of():

from pystreamapi import Stream
from pystreamapi.conditions import prime, even, one_of

Stream.of([1, 2, 3, 4, 5]) \
    .filter(one_of(even(), prime())) \
    .for_each(print) # 2, 3, 4, 5

Error Handling

Control error behavior per-operation with error_level():

from pystreamapi import Stream, ErrorLevel

Stream.of([" ", '3', None, "2", 1, ""]) \
    .error_level(ErrorLevel.IGNORE) \
    .map_to_int() \
    .sorted() \
    .for_each(print) # Output: 1 2 3

Available levels: RAISE (default), IGNORE, WARN. See the error handling docs for details.

Data Loaders

Load data from files directly into a stream — no manual parsing needed:

Loader Extra required Description
csv — CSV files with optional type casting and delimiter
json [json_loader] JSON files or strings (streaming via ijson)
xml [xml_loader] XML files or strings with node path access
yaml — YAML files or strings
toml — TOML files or strings
from pystreamapi import Stream
from pystreamapi.loaders import csv

Stream.of(csv("data.csv", delimiter=";")) \
    .map(lambda x: x.name) \
    .for_each(print)

Install all optional extras at once: pip install 'streams.py[all]'

See the data loaders docs for full usage.

Documentation

Full documentation: pystreamapi.pickwicksoft.org

Bug Reports

Bug reports can be submitted in GitHub's issue tracker.

Contributing

Contributions are welcome! Please submit a pull request or open an issue.

Metadata

Release files for streams.py 1.4.3

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

Source distribution (sdist)

Source distribution for streams.py 1.4.3
File Size Uploaded Provenance
streams_py-1.4.3.tar.gz 34.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for streams.py 1.4.3
File Interpreter ABI Platform
streams_py-1.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 81.7 kB

Release files / streams_py-1.4.3.tar.gz

Download URL streams_py-1.4.3.tar.gz
Size 34.9 kB
Tags Source
SHA-256 checksum
How to use checksums
445bd1af9c9279c5c986aa7869c5434df525a8e56ab200512b3025e9863f348d
BLAKE2b-256 checksum
How to use checksums
f3507185cec695a9d855fa6f71d9a98852f34d55f45c6dbee8867e006fbb657a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.13.1 Linux/6.17.0-1022-azure

Release files / streams_py-1.4.3-py3-none-any.whl

Download URL streams_py-1.4.3-py3-none-any.whl
Size 46.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1cb3d78fc7e8f4ac23e1e6662619fa949afbaf283c3e9bd277ddbd0bef47f678
BLAKE2b-256 checksum
How to use checksums
7e2400a8b2284abb1fb53f9268d250db248127d674456810bbcae663288908b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.13.1 Linux/6.17.0-1022-azure

Security for streams.py 1.4.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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