Pipe-like API over multiprocessing.shared_memory for fast numpy array transfer between processes.
Project description
mempipe
This package combines the simplicity of using Python's multiprocessing.Pipe() with the speed of multiprocessing.shared_memory.SharedMemory.
Meant for a multiprocessing data analysis pipeline where each process analyses the data and passes it to the next process for the next step.
The passed data can only be a numpy array.
Originally designed for a real-time Brain-Computer-Interface application.
Install
Using uv:
uv sync # set up the environment
uv run pytest # run the tests
How to use
Import the MemPipe class.
Make an instance object.
Call YourMemPipeInstance.Pipe(ex_array) instead of the multiprocessing.Pipe(duplex=False) in your applicaiton.
The ex_array is a numpy array that is used to infer the dtype and the size of the shared memory.
It must be the biggest array size that you will intend to pass between the processes.
If you .send() larger numpy arrays, they will be truncated to ex_array.shape.
If you .send() smaller numpy arrays, they will be handled just fine.
The pipe objects support poll(), recv(), and send().
Before calling recv(), you must call poll() and make sure it returns True (as you would normally).
All else is handled internally.
Currently, ./tests/test2.py shows an example using the latest API.
Simulation
This was done using an older version of the package
My simple simulation (found here: ./tests/test3.py) shows that passing a numpy array of $12000 \times 4000$ is much faster this way, compared to regular pipes.
20 repeatitions on the x-axis, and the execution time on the y-axis.
Project details
Release history Release notifications | RSS feed
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 mempipe-0.3.2.tar.gz.
File metadata
- Download URL: mempipe-0.3.2.tar.gz
- Upload date:
- Size: 92.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96c7569d217c7e6299a841bbb8c1ccb31dd6d2ab094d6a3980a265cb6cb659ef
|
|
| MD5 |
c86af4f8eb8c0e4e14616d7cb198cbc5
|
|
| BLAKE2b-256 |
894e30aca43c7bb7913525f9b9a8c0d12edc5deb13494f4f7bda565fcb84ecb3
|
Provenance
The following attestation bundles were made for mempipe-0.3.2.tar.gz:
Publisher:
publish.yml on AtMostafa/mempipe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mempipe-0.3.2.tar.gz -
Subject digest:
96c7569d217c7e6299a841bbb8c1ccb31dd6d2ab094d6a3980a265cb6cb659ef - Sigstore transparency entry: 1871937626
- Sigstore integration time:
-
Permalink:
AtMostafa/mempipe@b4c8a801f4cf8991ee8956dda7b906acaa714327 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AtMostafa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c8a801f4cf8991ee8956dda7b906acaa714327 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file mempipe-0.3.2-py3-none-any.whl.
File metadata
- Download URL: mempipe-0.3.2-py3-none-any.whl
- Upload date:
- Size: 28.7 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 |
ab2df272bc38f5d4b16f5b8885a438861d4c62a7ba5d0af0cb61dec6e1669f22
|
|
| MD5 |
7327b3bdc4a49f985367bc6c1bbea1b0
|
|
| BLAKE2b-256 |
8f87e532ac909e5ecfbded14bd5d60e132375cfae3b4c7f635e95a8719553e5d
|
Provenance
The following attestation bundles were made for mempipe-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on AtMostafa/mempipe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mempipe-0.3.2-py3-none-any.whl -
Subject digest:
ab2df272bc38f5d4b16f5b8885a438861d4c62a7ba5d0af0cb61dec6e1669f22 - Sigstore transparency entry: 1871937769
- Sigstore integration time:
-
Permalink:
AtMostafa/mempipe@b4c8a801f4cf8991ee8956dda7b906acaa714327 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AtMostafa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c8a801f4cf8991ee8956dda7b906acaa714327 -
Trigger Event:
workflow_dispatch
-
Statement type: