On Thu, Aug 25, 2011 at 23:27, Kibeom Kim <[email protected]> wrote:
> Hello,
>
> Q1. Is lazy loading ndarray from user defined data supplying function 
> possible?

No, not really.

> 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
> from SIGSEGV.
> 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
> http://stackoverflow.com/questions/2663456/write-a-signal-handler-to-catch-sigsegv)
> and it's impossible to know when to lock the region by mprotect again.

Well, if you're willing to go *that* far, you might was well make a
userspace file system with fuse and mmap a file within that.

  http://fuse.sourceforge.net/

You can even implement it in Python!

  http://pypi.python.org/pypi/fuse-python
  http://code.google.com/p/fusepy/

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to