Typed Stream classes for easier handling of iterables.
Project description
Typed Stream
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?
- 🇪🇺
- AGPL3 is too long
- Google EUPL Policy
Is it production-ready?
Probably.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file typed_stream-0.150.0.tar.gz
.
File metadata
- Download URL: typed_stream-0.150.0.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4fd33fc1763753e15527537e35e67be19dfb22a43067af27a851744be2a0618 |
|
MD5 | 248d9eed3b89f1161f452aafda22400a |
|
BLAKE2b-256 | 6aebd73c9edb1f5572a0a6b50efbb93b32faef36d6ebbf8eae6ae104f93cb01a |
File details
Details for the file typed_stream-0.150.0-py3-none-any.whl
.
File metadata
- Download URL: typed_stream-0.150.0-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 527166bbe4c9368b185c9072ce26ae311c592b22d2eb47f8a7a0522ca476ea10 |
|
MD5 | 81567fd699ac84f851154808b439c593 |
|
BLAKE2b-256 | 2eedfc762a4d195ff0ee903949142a7d1e548322a035240e1162a996e04751ae |