Zero-copy non-blocking pipe-like structure
Project description
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).
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamview-3.0.0.tar.gz.
File metadata
- Download URL: streamview-3.0.0.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b290b8e423f14f1950ed23d772a1e5b917750fd8e46d8e146784b1cb3e7921b6
|
|
| MD5 |
8eaf6babe61641fcd44e02c40d3e4129
|
|
| BLAKE2b-256 |
0de9adf67fe931106fd6e56b0fdbc2694789347312f6db1de937bec32b176b15
|
File details
Details for the file streamview-3.0.0-py3-none-any.whl.
File metadata
- Download URL: streamview-3.0.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ff790c1ad41616d15cdcb1faec0ea4daeb2d23ad88e8d9883c572ea9d5411ad
|
|
| MD5 |
3d3dc043cdfec49a1a30d7adb5b245c1
|
|
| BLAKE2b-256 |
d26253e944b075b612a301f46d6ef44292e984d2ff1bff291010e019dbd216eb
|