Use numpy array in shared memory for multiprocessing

To add to @unutbu’s (not available anymore) and @Henry Gomersall’s answers. You could use shared_arr.get_lock() to synchronize access when needed: shared_arr = mp.Array(ctypes.c_double, N) # … def f(i): # could be anything numpy accepts as an index such another numpy array with shared_arr.get_lock(): # synchronize access arr = np.frombuffer(shared_arr.get_obj()) # no data copying arr[i] = … Read more

Is it possible to get CMake to build both a static and shared library at the same time?

Yes, it’s moderately easy. Just use two “add_library” commands: add_library(MyLib SHARED source1.c source2.c) add_library(MyLibStatic STATIC source1.c source2.c) Even if you have many source files, you can place the list of sources in a Cmake variable, so it’s still easy to do. On Windows you should probably give each library a different name, since there is … Read more