I have a 1-D numpy array in memory
>>> x = np.arange(5)
I want to share this data with a separate and independent (not forked) C process on the same computer using shared memory.
I expect to do something like the following:
- Allocate a new block of shared memory from within Python
- Copy current data into that block
- Get dtype, length, and global address of the array and pass these to a C process (for now, we'll pass to the C process over a command line interface)
- Create an appropriately typed pointer within C to the memory address
- Do some trivial computation in C
What is the best way to acheive these steps? There appear to be several Python solutions to allocate array data in shared memory. All examples I can find involve sharing between two Python processes rather than between Python and another language.
Minimal examples are greatly welcomed.