[Numpy-discussion] lazy loading ndarray? (not from file, but from user function)
Thu Aug 25 23:27:31 CDT 2011
Q1. Is lazy loading ndarray from user defined data supplying function possible?
Q2. If possible, how can I implement it?
The closest method I can think of is, (which requires c++ posix)
1. create a memory region using mmap and protect read operation by mprotect.
2. add SIGSEGV signal handler to trap read operation on the memory
region, and the handler will provide appropriate user data and recover
3. slightly modify memmap class to use the above mmap (memmap is
already using mmap internally, so it's not a big deal)
but obviously, recovering from SIGSEGV requires removing mprotect (see
and it's impossible to know when to lock the region by mprotect again.
More information about the NumPy-Discussion