Figure out how to mmap a read only shared file with Cython
Closed this issue · 2 comments
Currently, we have to map the dataset read-write and private (requiring the overcommit hack) since Cython refuses to cast a read-only buffer into a cdef double array (and I can’t seem to persuade it to make a const array or anything…).
Likely tied to #19. Possibly just writing a cute C extension (that will compile against Py2 and Py3) that takes a read-only mmap and returns an object with a buffer interface that declares read-write, double floating point, suitable dimensions.
We can perhaps do this in Cython: the ability to call PyBuffer_GetPointer
and PyBuffer_ToContiguous
(via cimport cpython.buffer
) looks promising.
Doesn't help out the py2 problem. Perhaps there are methods exposed elsewhere which allow us to grab a pointer out of a mmap object, but I can't find them. This may require digging deeper into the mmap external type structure or other ickiness.