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.

Release files for streams.py 1.4.2

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.2
File Size Uploaded
streams_py-1.4.2.tar.gz 34.9 kB Details

Built distribution (wheel)

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

Total release size: 81.7 kB

Release files / streams_py-1.4.2.tar.gz

Download URL streams_py-1.4.2.tar.gz
Size 34.9 kB
Tags Source
SHA-256 checksum
How to use checksums
65c22e0269ebeb2658d4a03c1c17de608d21f4eb7aa9396d037f29c15fb50e8f
BLAKE2b-256 checksum
How to use checksums
6e42421330a4775f394a1d4f0bf7a51423e65b1170a28e0b2bb3a3b662cb4f9d
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.2-py3-none-any.whl

Download URL streams_py-1.4.2-py3-none-any.whl
Size 46.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af7924ae4c96682b064cdbc4908ffa353d2955f4844855a8bad43c0ce1397175
BLAKE2b-256 checksum
How to use checksums
2d5e3ec2f89477f3d81f451aa5550ee78584c5b7b6e29110874ebf798230527d
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 history Release notifications | RSS feed

This release

1.4.2 This release

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3

2 release files

0.2

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 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