pyshmem
pyshmem is a Python library for low-latency, cross-process exchange of fixed
shape NumPy arrays and CUDA-backed PyTorch tensors. CPU and GPU streams share
the same small create / open / write / read API.
A pyshmem stream is a capacity-one latest-value exchange, not a queue. Each write replaces the previous payload; readers get a consistent snapshot and can inspect missed-publication counters when producers run faster than consumers. It supports Linux and macOS; CUDA IPC is Linux-only. Windows is unsupported.
Documentation · API reference · Source · Issues · Changelog
Quick start
Create and publish from one process:
import numpy as np
import pyshmem
writer = pyshmem.create("frames", shape=(480, 640), dtype=np.float32)
writer.write(np.ones((480, 640), dtype=np.float32))
Attach and read from another:
import pyshmem
reader = pyshmem.open("frames")
frame = reader.read() # latest consistent snapshot
next_frame = reader.read_new(timeout=1) # wait for the next publication
print(reader.missed_writes)
reader.close()
Use the same API for CUDA by creating with gpu_device="cuda:0"; reads return
a CUDA torch.Tensor when attached to the GPU. Destroy persistent streams with
writer.unlink() when they are no longer needed.
See the quick start, usage guide, and GPU guide for lifecycle, locking, asyncio, CPU mirrors, failure recovery, and CLI examples.
Installation
CPU support:
pip install pyshmem
CUDA support (installs the PyTorch dependency):
pip install "pyshmem[gpu]"
See the installation guide for supported Python versions, platform requirements, development setup, and installation verification.
Performance
The repository includes both single-process microbenchmarks and a calibrated, spawned-process request/acknowledgement benchmark with an unsafe raw shared memory lower-bound comparison.
On the primary Linux development machine (Python 3.12, NumPy 2.2.6, PyTorch 2.10, RTX 5090), the spawned-process 64 KiB benchmark measured:
| Implementation | Round trips/s | p50 | p95 | p99 |
|---|---|---|---|---|
| pyshmem (CPU) | 13,940 | 60.45 µs | 112.86 µs | 115.94 µs |
| pyshmem (GPU IPC) | 4,900 | 189.89 µs | 232.83 µs | 241.00 µs |
| Raw shared memory polling | 16,952 | 53.58 µs | 104.10 µs | 108.54 µs |
The raw baseline omits pyshmem's locking, metadata validation, discovery, and
consistent snapshots. The GPU row is a separate spawned process mapping the
producer's CUDA tensor over torch IPC and reading a consistent device snapshot
each round trip. Results are machine-specific; run the harness on the target
deployment host (add --gpu for the CUDA baseline):
python benchmarks/benchmark_ipc.py \
--payload-bytes 65536 --minimum-seconds 1 --repeats 5 --gpu
See the benchmark documentation and the versioned result for methodology, CPU/GPU measurements, and limitations.
License and contact
pyshmem is licensed under GPL-3.0-only. Applications that distribute pyshmem or derivative work should evaluate the GPL's obligations.
Use GitHub issues for bugs and feature requests. See CONTRIBUTING.md for development, SUPPORT.md for compatibility and support scope, and SECURITY.md for private vulnerability reporting.
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 pyshmem-1.0.6.tar.gz.
File metadata
- Download URL: pyshmem-1.0.6.tar.gz
- Upload date:
- Size: 71.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63f4fdb158188060d6b9b60abfd9c6c8f46cf98ec3c743c0910a4484562fd15e
|
|
| MD5 |
436577483259f8d37b5bad72361b35cf
|
|
| BLAKE2b-256 |
1ce7df4fd15e76540f2875c4abc8d0eea3832e3aa9d131290ccd2cc4c2ed3375
|
Provenance
The following attestation bundles were made for pyshmem-1.0.6.tar.gz:
Publisher:
pypi.yml on jacotay7/pyshmem
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyshmem-1.0.6.tar.gz -
Subject digest:
63f4fdb158188060d6b9b60abfd9c6c8f46cf98ec3c743c0910a4484562fd15e - Sigstore transparency entry: 2142572072
- Sigstore integration time:
-
Permalink:
jacotay7/pyshmem@adf67c690d8172dcc60ff2273333e3fbe5fcddc0 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/jacotay7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@adf67c690d8172dcc60ff2273333e3fbe5fcddc0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyshmem-1.0.6-py3-none-any.whl.
File metadata
- Download URL: pyshmem-1.0.6-py3-none-any.whl
- Upload date:
- Size: 44.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28bbd1b381631567fffe3f092dda6652c1fb4f71f7878d7045c58fd457cbb804
|
|
| MD5 |
1013c39f40dc2e7144fccca819be64b5
|
|
| BLAKE2b-256 |
6b7f432eea77ae9ba744ee679fcba00a7764b27043000e7dced945f51b045a34
|
Provenance
The following attestation bundles were made for pyshmem-1.0.6-py3-none-any.whl:
Publisher:
pypi.yml on jacotay7/pyshmem
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyshmem-1.0.6-py3-none-any.whl -
Subject digest:
28bbd1b381631567fffe3f092dda6652c1fb4f71f7878d7045c58fd457cbb804 - Sigstore transparency entry: 2142572164
- Sigstore integration time:
-
Permalink:
jacotay7/pyshmem@adf67c690d8172dcc60ff2273333e3fbe5fcddc0 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/jacotay7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@adf67c690d8172dcc60ff2273333e3fbe5fcddc0 -
Trigger Event:
release
-
Statement type: