Does multiprocessing copy the object in this scenario?
问题 import multiprocessing import numpy as np import multiprocessing as mp import ctypes class Test(): def __init__(self): shared_array_base = multiprocessing.Array(ctypes.c_double, 100, lock=False) self.a = shared_array = np.ctypeslib.as_array(shared_array_base) def my_fun(self,i): self.a[i] = 1 if __name__ == "__main__": num_cores = multiprocessing.cpu_count() t = Test() def my_fun_wrapper(i): t.my_fun(i) with mp.Pool(num_cores) as p: p.map(my_fun_wrapper, np.arange(100)) print(t.a) In the code