Skip to main content

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
  • BufferedIOBase compatible 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, copy and deepcopy support.

    Extends: BufferedIOBase

    • __len__() -> int

      Number of views held in stream

    • nbytes -> int

      Number of bytes held in stream

    • views -> Iterable[memoryview]

      Peeking iterator over views

    • __getitem__(index) -> memoryview

      Peek a view from the stream

    • unreadview(v: memoryview) -> int

      Unread a view into the stream

    • readview() -> memoryview

      Read a view from stream

    • readviews() -> Iterable[memoryview]

      Read all views from stream

    • unwriteview() -> memoryview

      Unwrite a view from the stream

    • writeview(v: memoryview) -> int

      Write a view into the stream

    • writeviews(vs: Iterable[memoryview]) -> int

      Write many views into the stream

    • frombuffer(b: Buffer) -> Stream

      Construct a stream from a buffer

    • toview() -> memoryview

      Transform stream to contiguous view (may copy)

    • copy() -> Stream

      Shallow copy of stream

Functions

  • byteview(b: Buffer) -> memoryview

    Return 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)

Source distribution for streamview 3.0.1
File Size Uploaded
streamview-3.0.1.tar.gz 17.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for streamview 3.0.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page