PYME.util.shmarray.shmarray module¶
shmarray.py
Shared memory array implementation for numpy which delegates all the nasty stuff to multiprocessing.sharedctypes.
Copyright (c) 2010, David Baddeley
- PYME.util.shmarray.shmarray.create(shape, dtype='d', order=None)¶
Create an uninitialised shared array. Avoid object arrays, as these will almost certainly break as the objects themselves won’t be stored in shared memory, only the pointers
- PYME.util.shmarray.shmarray.create_copy(a)¶
create a a shared copy of an array
- PYME.util.shmarray.shmarray.ones(shape, dtype='d')¶
Create an shared array initialised to ones. Avoid object arrays, as these will almost certainly break as the objects themselves won’t be stored in shared memory, only the pointers
- class PYME.util.shmarray.shmarray.shmarray(ctypesArray, shape, dtype=<class 'float'>, strides=None, offset=0, order=None)¶
Bases:
ndarray
subclass of ndarray with overridden pickling functions which record dtype, shape etc… but defer pickling of the underlying data to the original data source.
Doesn’t actually handle allocation of the shared memory - this is done in create, and zeros, ones, (or create_copy) are the functions which should be used for creating a new shared memory array.
TODO - add argument checking to ensure that the user is passing reasonable values.
- PYME.util.shmarray.shmarray.zeros(shape, dtype='d', order=None)¶
Create an shared array initialised to zeros. Avoid object arrays, as these will almost certainly break as the objects themselves won’t be stored in shared memory, only the pointers