Hi! First time poster to the list, long time happy user of NumPy (thank you, 
devs!!)

I created a bit of a wrapper for using `ndarray` with Py 3.8+ 
`multiprocessing.shared_memory`. I really like the ability to use 
`SharedMemory` with `ndarray` via the `buffer` arg. (as in 
https://docs.python.org/3/library/multiprocessing.shared_memory.html#multiprocessing.shared_memory.SharedMemory)
 However, it seemed a bit clunky to worry about passing the SharedMemory object 
or name, dtype, and shape to reconstruct the `ndarray` in other processes. I 
came up with this SharedNDArray class that encapsulates that information and 
provides an ephemeral `ndarray` interface: 
https://gitlab.com/osu-nrsg/shared-ndarray2. It's especially meant for use in a 
`SharedMemoryManager` context manager.

I shared it on r/Python and someone suggested I share it here for your input 
(and maybe even integration into NumPy rather than the lone-wolf project it 
currently is).

I'm happy to receive any suggestions/input/criticism.

As an aside, I discovered that it's not at all trivial and, at the moment, not 
technically possible to define all the possible typing overloads of ndarray 
`__setitem__` and `__getitem__`. Stll, I enjoyed making use of 
np.typing.NDArray.

Thanks for your consideration,
Randy
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to