taylorism.util

Various utility classes and functions to be used with the taylorism package.

Classes

class taylorism.util.SharedNumpyArray(array)[source]

Bases: object

Wrapper to multiprocessing.Array, for it to be shared in memory among Workers, while being handled as a numpy.ndarray or numpy.ma.masked_array.

Parameters:

array – initialize the SharedNumpyArray with this one, supposed to be either a multiprocessing.Array, a numpy.ndarray or a numpy.ma.masked_array.

  • constructing a SharedNumpyArray from a multiprocessing.Array will not duplicate data but make the SharedArray be a pointer to the initial array;

  • constructing from a numpy array will duplicate data, and so the initial array will no longer be consistent with this one.

The process-safetiness of the shared array is ensured (cf. multiprocessing.Array) through the use of SharedNumpyArray.acquire() and .release(), but this is of the responsability of the user implementing the Worker’s inner task.