A versatile, high-performance ring buffer implementation for Python supporting standard lists, NumPy arrays, and shared memory for inter-process communication.
Project description
Ring Buffer
A high-performance, zero-copy ring buffer implementation for Python. This library provides a seamless way to handle streaming data using standard NumPy arrays or Shared Memory for ultra-fast inter-process communication (IPC).
Key Features
-
Zero-Copy Design: Read operations return a view of the buffer rather than a copy, minimizing overhead.
-
Multiprocessing Ready: Built-in support for SharedMemory to move data between processes at lightning speed.
-
NumPy Integration: Native support for NumPy arrays, allowing for direct mathematical operations on buffer data.
-
Lock-Free Performance: Optimized for Single-Producer Single-Reader (SPSR) scenarios.
🚀 Get Started
Prerequisites
Python: 3.11 or higher
Optional: numpy (required for NumPy-specific buffer classes)
Installation
Using pip:
# Basic installation
pip install shm-ring-buffer
# With NumPy support
pip install shm-ring-buffer[numpy]
Using poetry:
# Basic installation
poetry add shm-ring-buffer
# With NumPy support
poetry add shm-ring-buffer -E numpy
🛠 Usage & Architecture
[!WARNING] Single-Producer Single-Reader (SPSR): This implementation is lock-free to maximize throughput. It is not thread-safe for multiple concurrent writers or multiple concurrent readers. Ensure your architecture follows the SPSR pattern.
Shared Memory IPC
Shared memory is the fastest method for IPC in Python. This library implements two primary shared memory buffers:
BytesShmRingBuffer: Optimized for raw byte streams.
NumpyShmRingBuffer: Optimized for structured numerical data.
Implementation Note:
One process must initialize the buffer with create=True, while the consumer/other side should set create=False. Always call .close() to properly release system resources.
The Zero-Copy Workflow
To maintain high performance, the buffer returns a view of the data.
Read: Access the current item.
Process: Use the data (or copy it if you need it to persist).
Release: You must call .release() after processing to signal that the slot is available for the producer to overwrite.
🗺️ Roadmap
-
High-performance multiprocessing.shared_memory implementation.
-
CuPy implementation for hardware acceleration via NVIDIA GPUs (CUDA).
👥 Authors
Project details
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 shm_ring_buffer-1.2.1.tar.gz.
File metadata
- Download URL: shm_ring_buffer-1.2.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e0c559eada8e2310d305a023af26ad9ee23694a92fd78caff4dad6cf2b6d929
|
|
| MD5 |
facab797aba5a02b1849f07a118f9619
|
|
| BLAKE2b-256 |
85a00782bb238bd62fdab0ab6ef169a62e71925da7227ed77bbaf4454b1bdf98
|
Provenance
The following attestation bundles were made for shm_ring_buffer-1.2.1.tar.gz:
Publisher:
publish.yml on loic-combis/shm-ring-buffer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shm_ring_buffer-1.2.1.tar.gz -
Subject digest:
0e0c559eada8e2310d305a023af26ad9ee23694a92fd78caff4dad6cf2b6d929 - Sigstore transparency entry: 1188645964
- Sigstore integration time:
-
Permalink:
loic-combis/shm-ring-buffer@d924efd77075a194dc1386401b17d4e0d5d309d4 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/loic-combis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d924efd77075a194dc1386401b17d4e0d5d309d4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file shm_ring_buffer-1.2.1-py3-none-any.whl.
File metadata
- Download URL: shm_ring_buffer-1.2.1-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e13eb0b088f549314acb6e4dd8aa2e160da3555607020da37541e7d5166cbab5
|
|
| MD5 |
3187bc9ebbcb66161e110cd8e1559edc
|
|
| BLAKE2b-256 |
be7f532dbc4dabd97fc98852cd6ea9d18549df03ec59a07418761e0d4171285a
|
Provenance
The following attestation bundles were made for shm_ring_buffer-1.2.1-py3-none-any.whl:
Publisher:
publish.yml on loic-combis/shm-ring-buffer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shm_ring_buffer-1.2.1-py3-none-any.whl -
Subject digest:
e13eb0b088f549314acb6e4dd8aa2e160da3555607020da37541e7d5166cbab5 - Sigstore transparency entry: 1188645967
- Sigstore integration time:
-
Permalink:
loic-combis/shm-ring-buffer@d924efd77075a194dc1386401b17d4e0d5d309d4 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/loic-combis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d924efd77075a194dc1386401b17d4e0d5d309d4 -
Trigger Event:
release
-
Statement type: