aiostream
Generator-based operators for asynchronous iteration
Synopsis
aiostream provides a collection of stream operators that can be combined to create asynchronous pipelines of operations.
It can be seen as an asynchronous version of itertools, although some aspects are slightly different. Essentially, all the provided operators return a unified interface called a stream. A stream is an enhanced asynchronous iterable providing the following features:
Operator pipe-lining - using pipe symbol |
Repeatability - every iteration creates a different iterator
Safe iteration context - using async with and the stream method
Simplified execution - get the last element from a stream using await
Slicing and indexing - using square brackets []
Concatenation - using addition symbol +
Stream operators
The stream operators are separated in 7 categories:
creation |
iterate, preserve, just, call, empty, throw, never, repeat, count, range |
transformation |
|
selection |
take, takelast, skip, skiplast, getitem, filter, until, takewhile, dropwhile |
combination |
|
aggregation |
|
advanced |
|
timing |
|
miscellaneous |
Demonstration
The following example demonstrates most of the streams capabilities:
import asyncio
from aiostream import stream, pipe
async def main():
# Create a counting stream with a 0.2 seconds interval
xs = stream.count(interval=0.2)
# Operators can be piped using '|'
ys = xs | pipe.map(lambda x: x**2)
# Streams can be sliced
zs = ys[1:10:2]
# Use a stream context for proper resource management
async with zs.stream() as streamer:
# Asynchronous iteration
async for z in streamer:
# Print 1, 9, 25, 49 and 81
print('->', z)
# Streams can be awaited and return the last value
print('9² = ', await zs)
# Streams can run several times
print('9² = ', await zs)
# Streams can be concatenated
one_two_three = stream.just(1) + stream.range(2, 4)
# Print [1, 2, 3]
print(await stream.list(one_two_three))
# Run main coroutine
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
More examples are available in the example section of the documentation.
Installation
You can install aiostream from PyPI as the aiostream package.
Contact
Vincent Michel: vxgmichel@gmail.com
Release files for aiostream 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiostream-0.8.0.tar.gz | 44.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiostream-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 86.7 kB
Release files / aiostream-0.8.0.tar.gz
| Download URL | aiostream-0.8.0.tar.gz |
|---|---|
| Size | 44.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c281608c5afa1f313a7bdcd7b9c286953b22d704bdbaef8a0f51480bdaca98c0
|
|
BLAKE2b-256 checksum How to use checksums |
199ecb65144bda3298d98960241ca3ead20adc8203ce348923e2b2e76f6cc60e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency logRelease files / aiostream-0.8.0-py3-none-any.whl
| Download URL | aiostream-0.8.0-py3-none-any.whl |
|---|---|
| Size | 41.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25a431a88aa3c729de4fd61310f34077bb100c1a55c7b476d28692facf7b282a
|
|
BLAKE2b-256 checksum How to use checksums |
7ea16c750f1e1f5f4d7b3e2fe239370929617f8fb6b29102c345cd8be7c9a700
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency log