4 ms·
I've been trying to tackle precisely that problem. Would someone please help me out and point me at a way of efficiently exposing a read-only block of memory t
by palish 15y ago
I've been trying to tackle precisely that problem.
Would someone please help me out and point me at a way of efficiently exposing a read-only block of memory to Python?
EDIT: Looks like "MemoryView" introduced in 2.7 is the answer.
- veyron 15y ago2.7 introduced memoryview, and there are a slew of C API routines to interact with it ... as for shared memory, have you tried just mmap'ing the node from /dev/shm ?
- palish 15y agoAha! That sounds like just the ticket. I hope it's easy to use. A million thank-you's, and a Salami. EDIT: I just saw your edit. That's what I'm doing --- shm_open(), ftruncate(), then mmap(). A little annoying that it doesn't automatically kill the shared memory when the program terminates, but still...
- veyron 15y agoIt's pretty slick, and I've had good results using it in conjunction with a C program that generates data.
- deleted 15y ago[deleted]