Skip to main content

Typed Stream classes for easier handling of iterables.

Project description

Typed Stream

License Python Implementation Total lines Code size Style: Black Imports: isort Coverage

Downloads Downloads Downloads

The Stream class is an iterable with utility methods for transforming it.

This library heavily uses itertools for great performance and simple code.

Examples

>>> import typed_stream
>>> # Get sum of 10 squares
>>> typed_stream.Stream.range(stop=10).map(lambda x: x * x).sum()
285
>>> # same as above
>>> sum(typed_stream.Stream.counting().limit(10).map(pow, 2))
285
>>> # sum first 100 odd numbers
>>> typed_stream.Stream.counting(start=1, step=2).limit(100).sum()
10000
>>> (typed_stream.Stream.counting()
...     .filter(typed_stream.functions.is_odd).limit(100).sum())
10000
>>> (typed_stream.Stream.counting()
...     .exclude(typed_stream.functions.is_even).limit(100).sum())
10000
>>> import typed_stream.functions
>>> # Get the longest package name from requirements-dev.txt
>>> (typed_stream.FileStream("requirements-dev.txt")
...     .filter()
...     .exclude(typed_stream.functions.method_partial(str.startswith, "#"))
...     .map(str.split, "==")
...     .starmap(lambda name, version = None: name)
...     .max(key=len))
'flake8-no-implicit-concat'

In examples are more complex examples using Streams.

Not yet asked questions

I'll try to answer questions that could occur.

What do the versions mean?

I try to follow something similar to sem-ver. For versions before 1.0.0 this means the format is 0.<major>.<patch>. Any change that could be considered a breaking-change (adding things is not a breaking change) increases the major part. If only patch has changed, there was no breaking-change. I try to avoid changes that break my own code, so even if major has been changed, it should probably be safe to upgrade.

Why are there no changelogs?

I'm too lazy. I don't know of anybody using this (except me) and I don't need to write changelogs for myself. If you need changelogs, please create an issue.

Why EUPL-1.2-or-later?

Is it production-ready?

Probably.

Project details


Download files

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

Source Distribution

typed_stream-0.155.0.tar.gz (28.2 kB view details)

Uploaded Source

Built Distribution

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

typed_stream-0.155.0-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file typed_stream-0.155.0.tar.gz.

File metadata

  • Download URL: typed_stream-0.155.0.tar.gz
  • Upload date:
  • Size: 28.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for typed_stream-0.155.0.tar.gz
Algorithm Hash digest
SHA256 c8eb93a6a94da14a9868d266f90f07a436c35dde62211378873e12705771a4a4
MD5 bb35724bbf7b7beea768c9e5f3dbf9f1
BLAKE2b-256 f09a43f33313be62769c76d5f5d4458bf96905bae90f616191222ba5bb90cd75

See more details on using hashes here.

File details

Details for the file typed_stream-0.155.0-py3-none-any.whl.

File metadata

  • Download URL: typed_stream-0.155.0-py3-none-any.whl
  • Upload date:
  • Size: 35.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for typed_stream-0.155.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7dba0c9a6d1700d6028aecf45daefcd5a058ea27f4e2aaf017347cb348e96af
MD5 85e4d8a2263337678365c7d440040695
BLAKE2b-256 2b57da0811884d9c38582c7be578ea1bc1bc62e05e676a92243318f10abfd865

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page