The piece of code that I have looks something like this:
glbl_array = # a 3 Gb array def my_func( args, def_param = glbl_array): #do stuff on args and def_param if __name__ == '__main__': pool = Pool(processes=4) pool.map(my_func, range(1000))
Is there a way to make sure (or encourage) that different processes do not receive a copy of glbl_array, but share it. If there is no way to stop the copy, I will go with the memmapped array, but my access patterns are not very regular, so I expect memmapped arrays to be slower. Above was like the first thing to try. This is on Linux. I just wanted advice from Stackoverflow and I don't want to annoy the system administrator. Do you think this will help if the second parameter is a genuine immutable object, for example glbl_array.tostring() .
python numpy multiprocessing
san Apr 05 2018-11-11T00: 00Z
source share