[Numpy-discussion] does an ndarray have a "hook" for a dictionary attribute ?

Sebastian Haase seb.haase@gmail....
Thu Nov 12 03:38:37 CST 2009


Hi,

I hope my subject line is not entirely incomprehensible:
I remember there was a discussion (some time ago) that every ndarray
instance should get an extra dictionary (or just a "hook" for it, to
minimize the memory foot print) for "application specific" /
"auxiliary" data.
What is the current state on this ?

The issue at hand is, that my image analysis development platform
supports various file types by now, and I usually load images straight
into an ndarray (e.g. using PIL for standard types).
This is fine for most needs depending only on the pixel values.
However, now I would like to save images back after performing some
operation on it.
So it would be nice if I could "attach" the original filename to the
respective ndarray.
Is this possible with standard ndarray (using the mentioned dictionary
attribute)
or
do I need to subclass ndarray to make such a ndarray_with_dict
?

(For the latter it would be very helpful to get a hint on how to make
such a "minimal" ndarray-subclass . I remember some issues involving
some special __new__ methods, that I don't entirely remember by
heard..)

Thanks,


Sebastian Haase


More information about the NumPy-Discussion mailing list