python - RawArray from numpy array? -
I want to share a numpy array in multiple processes. The process only reads the data, so I want to avoid making copies. I know how to do it if I can start with a I also need some of your needs: A) A large numerical array has been given, b) Processes it Need to share between a bunch of c) only for reading etc. And, for this, I am using some of the following lines: Where in my case, MannPrera is 3D to share as genuine, I used the following style and it worked so far Does. multiprocessing.sharedctypes.RawArray and then create a numpy array using the
numpy.frombuffer . But what if I get an oval array initially given? Is there any way to start a wireless connection with data of fake array without copying data? Or is there another way to share data in processes without copying it there?
mynparray = #initialize a file shrarr_base_ptr = A large array of rawArray (ctypes.c_double, lane * rows * columns) shrarr_ptr = Np.frombuffer (shrarr_base_ptr) shrarr_ptr = mynparray
inq1 = queue () inq2 = queue () outq = queue () p1 = process (target = myfunc1, arg = (inq1, outq,)) p1.start () inq1.put ((Shrarr_ptr,) p2 = process (target = myfunc2, argument = (inq2, outq,)) p2.start () inq2.put ((shrarr_ptr,)) inq1.close () inq2.close () inq1.join_thread () Inq2.join_thread () .....
Comments
Post a Comment