Pure Python implementation of the ZeroIPC shared memory protocol. This is not a binding to C++ code - it's a standalone implementation that follows the same binary specification.
- Pure Python: No compilation required
- NumPy integration: Efficient array operations
- Duck typing: Users specify types at runtime
- Zero-copy: Direct memory mapping via mmap
- Cross-language: Interoperates with C++ and other implementations
pip install -e .python -m pytest tests/from zeroipc import Memory, Array
import numpy as np
# Open or create shared memory
mem = Memory("/sensor_data", size=10*1024*1024) # 10MB
# Create or open array with runtime type
data = Array(mem, "temperature", capacity=1000, dtype=np.float32)
# NumPy-like interface
data[0] = 23.5
data[:10] = np.arange(10)
# Direct NumPy array access
print(data.data.mean())Memory(name: str, size: int = 0, max_entries: int = 64)name: Shared memory identifier (e.g., "/myshm")size: Size in bytes (0 to open existing)max_entries: Maximum table entries
Array(memory: Memory, name: str, capacity: int = None, dtype = None)memory: Memory instancename: Array identifiercapacity: Number of elements (None to open existing)dtype: NumPy dtype or type string
Since Python uses duck typing, users must specify types when accessing data:
# Integer array
int_array = Array(mem, "counts", dtype=np.int32)
# Float array
float_array = Array(mem, "values", dtype=np.float64)
# Structured array
coord_dtype = np.dtype([('lat', 'f4'), ('lon', 'f4')])
coords = Array(mem, "locations", dtype=coord_dtype)- Python 3.8+
- NumPy
- POSIX shared memory support (Linux/macOS)
- Full synchronization primitives: Mutex, RWLock, Monitor, Event, Semaphore, Barrier, Latch, Once, Signal
- Codata structures: Future, Lazy, Stream, Channel
- Cross-process validation tests using multiprocessing
The Python implementation emphasizes:
- Simplicity through duck typing
- NumPy compatibility for scientific computing
- Pure Python for easy distribution
- Binary compatibility with other language implementations