python-System V style shared memory
This support allows creation of memory segments that can be shared between Python processes and, consequently, help avoid (de)serialization costs when sharing data between processes.
shm = shared_memory.SharedMemory(create=False, size=a.nbytes,name='ShareMemory') |
Things to Remember
- The memoryview built-in type provides a zero-copy interface for reading and writing slices of objects that support Python’s high performance buffer protocol.
- The bytearray built-in type provides a mutable bytes-like type that can be used for zero-copy data reads with functions like socket.recv_from.
- A memoryview can wrap a bytearray, allowing for received data to be spliced into an arbitrary buffer location without copying costs.