python - RawArray from numpy array? -
python - RawArray from numpy array? -
i want share numpy array across multiple processes. processes read data, want avoid making copies. know how if can start multiprocessing.sharedctypes.rawarray
, create numpy array using numpy.frombuffer
. if given numpy array? there way initialize rawarray numpy array's info without copying data? or there way share info across processes without copying it?
i'm not sure if copies info internally, pass flat array:
a = numpy.random.randint(1,10,(4,4)) >>> array([[5, 6, 7, 7], [7, 9, 2, 8], [3, 4, 6, 4], [3, 1, 2, 2]]) b = rawarray(ctypes.c_long, a.flat) >>> b[:] [5, 6, 7, 7, 7, 9, 2, 8, 3, 4, 6, 4, 3, 1, 2, 2]
python arrays numpy multiprocessing
Comments
Post a Comment