Provide shared memory data structures!
Project description
Shared Memory Data Structure
This package allows you to use your data structures like numpy arrays in the shared memory environment between two or more python processes. This library simplifies the use of shared memory data structures as you don't need to manually manage shared memory.
SharedArray example:
Process #1
from shared_ds import SharedArray
# Create shared memory and put you numpy array into that memory segment.
shared_np_array = SharedArray.from_array(np_array)
shm_descriptor = shared_np_array.to_json()
Process #2
from shared_ds import SharedArray
# Attaches to existing shared memory and reads numpy array representation.
shared_np_array = SharedArray.from_json(shm_descriptor)
shm_descriptor = shared_np_array.to_json()
io.BytesIO example:
Process #1
from shared_ds import SharedBytesIO
import io
# Create shared memory and put content of passed BytesIO into that memory segment.
data_to_store = io.BytesIO(b'data which we want to store')
shared_memory = SharedBytesIO.from_bytes_io(data_to_store)
shm_descriptor = shared_memory.to_json()
Process #2
from shared_ds import SharedBytesIO
# Attaches to existing shared memory and gets io.BytesIO content.
shared_memory = SharedBytesIO.from_json(shm_descriptor)
data = shared_memory.get_data()
Currently supported data structures:
- Numpy Array
- io.BytesIO
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
shared_ds-0.0.5.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for shared_ds-0.0.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d6ce53b9a549933dea6f1ce5f2953fffe6f83d556d674dab165c1cfa6c1b708 |
|
MD5 | 1445bba9dc18fa0a4773a8463981aa65 |
|
BLAKE2b-256 | cd0237ad4c209bde3f2e746fbfd04e157b72b03343f71d58e19d4d86e9618748 |