Zero-copy shared memory for Python via cffi. Includes optional NumPy integration for ML/data workflows.
pip install zinc-shmRequires libzinc_core.dylib / libzinc_core.so built and findable.
cargo build --release --manifest-path core/Cargo.toml
pip install -e adapters/pythonfrom zinc import SharedRegion
# Process A — create
r = SharedRegion.create("/my-data", 4096)
buf = r.as_buffer()
buf[0:8] = (42).to_bytes(8, 'little')
r.notify()
# Process B — open
r2 = SharedRegion.open("/my-data")
buf2 = r2.as_buffer()
value = int.from_bytes(buf2[0:8], 'little')
print(value) # 42import numpy as np
from zinc import SharedRegion
r = SharedRegion.create("/tensor", 4096)
arr = r.as_numpy(dtype=np.float32) # zero-copy!
arr[0] = 3.14159
arr[1] = 2.71828
r.notify()Create a new shared region.
name: str— shm namecapacity: int— size in bytes (page-aligned)
Open an existing shared region.
Zero-copy memoryview of the shared region.
Zero-copy NumPy array view.
Signal all waiters.
Block until notified.
Release the handle. Use as context manager with with:
with SharedRegion.create("/data", 4096) as r:
arr = r.as_numpy(dtype=np.float64)
arr[0] = 1.0pytest adapters/python/tests/ -vcd adapters/python
pip install build twine
python -m build
twine upload dist/*| OS | Status |
|---|---|
| Linux | ✅ |
| macOS | ✅ |
Windows is not supported. Zinc requires POSIX
shm_open+mmap.