streamview
Zero-copy non-blocking pipe-like structure
Stream primitive extending Python's standard I/O model with zero-copy and scatter/gather semantics.
- Zero-copy operations using
memoryview BufferedIOBasecompatible API- Non-blocking I/O semantics
- Compatible with existing Python I/O tooling and libraries
- Efficient handling of fragmented buffers without unnecessary copies
- Explicit ownership transfer of buffers
- Lightweight stream copies with shared underlying buffers
- Supports both high-level I/O usage and low-level buffer access
- Lightweight and dependency-free
- Designed for high-throughput data pipelines
Example
from streamview import Stream
stream = Stream()
stream.write(b"hello")
stream.write(b"world")
print(stream)
# <Stream views=2 nbytes=10>
print(bytes(stream.read()))
# b"helloworld"
Install
Production
pip install streamview
Development
git clone https://github.com/hpca-uji/streamview.git
cd streamview
pip install -e .
Documentation
Classes
-
Stream()Zero-copy non-blocking pipe-like
Interface mimics a non-blocking BufferedIOBase, but operations return memoryviews instead of bytes.
Operations consume the stream. Operations are not thread-safe. Reader is responsible of releasing views. Writer hands off responsibility over views.
Stream has
with,bytes,bool,copyanddeepcopysupport.Extends:
BufferedIOBase-
__len__() -> intNumber of views held in stream
-
nbytes -> intNumber of bytes held in stream
-
views -> Iterable[memoryview]Peeking iterator over views
-
__getitem__(index) -> memoryviewPeek a view from the stream
-
unreadview(v: memoryview) -> intUnread a view into the stream
-
readview() -> memoryviewRead a view from stream
-
readviews() -> Iterable[memoryview]Read all views from stream
-
unwriteview() -> memoryviewUnwrite a view from the stream
-
writeview(v: memoryview) -> intWrite a view into the stream
-
writeviews(vs: Iterable[memoryview]) -> intWrite many views into the stream
-
frombuffer(b: Buffer) -> StreamConstruct a stream from a buffer
-
toview() -> memoryviewTransform stream to contiguous view (may copy)
-
copy() -> StreamShallow copy of stream
-
Functions
-
byteview(b: Buffer) -> memoryviewReturn a byte view of a buffer
Acknowledgments
The library has been partially supported by:
- Project PID2023-146569NB-C22 "Inteligencia sostenible en el Borde-UJI" funded by the Spanish Ministry of Science, Innovation and Universities.
- Project C121/23 Convenio "CIBERseguridad post-Cuántica para el Aprendizaje FEderado en procesadores de bajo consumo y aceleradores (CIBER-CAFE)" funded by the Spanish National Cybersecurity Institute (INCIBE).
Metadata
Release files for streamview 3.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| streamview-3.0.1.tar.gz | 17.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| streamview-3.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.2 kB
Release files / streamview-3.0.1.tar.gz
| Download URL | streamview-3.0.1.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac8fe3ca7511429c89b350388f66b7068e8ae9ea01bc062c3bb0d97b9beff9fd
|
|
BLAKE2b-256 checksum How to use checksums |
e46d08b20e7da9e8d88e7f6ae6c2d0f6018b8580d196d160de59839c32aa2b68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / streamview-3.0.1-py3-none-any.whl
| Download URL | streamview-3.0.1-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37887595d0ccc037ec2fd5def3bc3139c7ba190d9b361d41951b012146545490
|
|
BLAKE2b-256 checksum How to use checksums |
86193ec49db00d8bd4ed5c52c95528d19aaa37f4ce2c7605ec8a95e3e87980f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|