[Numpy-discussion] Trying out Numeric3

Chris Barker Chris.Barker at noaa.gov
Fri Mar 25 09:53:57 EST 2005


Scott Gilbert wrote:

> I don't know what particular meta data you plan to store with the buffer
> itself, and I'm going to resist the urge to guess.  You probably have some
> very good use cases.  What are you planning?

I don't know what Travis has in mind, but I thought I'd bring up a use 
case that I think provides some of the motivation for this.

There are any number of Third arty extensions that could benefit from 
being able to directly read the data in Numeric* arrays: PIL, wxPython, 
etc. Etc. My personal example is wxPython:

At the moment, you can pass a Numeric or numarray array into wxPython, 
and it will be converted to a wxList of wxPoints (for instance), but 
that is done by using the generic sequence protocol, and a lot of type 
checking. As you can imagine, that is pretty darn slow, compared to just 
typecasting the data pointer and looping through it. Robin Dunn, quite 
reasonably, doesn't want wxPython to depend on Numeric, so that's what 
we've got.

My understanding of this memory object is that an extension like 
wxPython wouldn't not need to know about Numeric, but could simply get 
the memory Object, and there would be enough meta-data with it to 
typecast and loop through the data. I'm a bit skeptical about how this 
would work. It seems that the metadata required would be the full set of 
stuff in an array Object already:

type
dimensions
strides

This could be made a bit simpler by allowing only contiguous arrays, but 
then there would need to be a contiguous flag.

To make use of this, wxPython would have to know a fair bit about 
Numeric Arrays anyway, so that it can check to see if the data is 
appropriate. I guess the advantage is that while the wxPython code would 
have to know about Numeric arrays, it wouldn't have to include Numeric 
headers or code.

-Chris









-- 
Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the NumPy-Discussion mailing list