[Numpy-discussion] lazy loading ndarrays

Craig Yoshioka craigyk at me.com
Tue Jul 26 20:11:35 EDT 2011


I want to subclass ndarray to create a class for image and volume data, and when referencing a file I'd like to have it load the data only when accessed.  That way the class can be used to quickly set and manipulate header values, and won't load data unless necessary.  What is the best way to do this?  Are there any hooks I can use to load the data when an array's values are first accessed or manipulated?  I tried some trickery with __array_interface__ but couldn't get it to work very well.  Should I just use a memmapped array, and give up on a purely 'lazy' approach?

Thanks, and cheers!
-Craig



More information about the NumPy-Discussion mailing list