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.150.1.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

typed_stream-0.150.1-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typed_stream-0.150.1.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for typed_stream-0.150.1.tar.gz
Algorithm Hash digest
SHA256 b3d0baef4cf34f20d9f5ae81f6597c010f389d93e25616a2e7fc4970b87b49f5
MD5 a9099ec38e5563f25fb4ca5292e0deed
BLAKE2b-256 0df6c95081045b7a091b9e8c9ea0545dcefbb32b2eb15f14b0657418b5a085a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typed_stream-0.150.1-py3-none-any.whl
Algorithm Hash digest
SHA256 313e0be836ae5ee76c307b82e41628c60592247d1c719cdef47a73fc4349a7a1
MD5 739c7d781f6157c35dfa58f87cf4f952
BLAKE2b-256 58127ce783fee92c6a4c0335783bfd26f10b20972310381459e07532e86f5cf5

See more details on using hashes here.

Supported by

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