[Numpy-discussion] iterating over an array

Chris Barker Chris.Barker at noaa.gov
Fri Jan 14 11:54:26 CST 2005


Francesc Altet wrote:
> That shows that numarray indexing is slower than Numeric, but not by a large
> extent (just a 40%). The real problem with numarray (for Ralf's example) is,
> as is already known, array creation time.

Thanks for clearing this up. The case I care about(at the moment) is in 
wxPython's "PointListHelper". It converts whatever Python sequence you 
give it into a wxList of wxPoints. The sequence you give it needs to 
look something like a list of (x,y) tuples. An NX2 Numeric or Numarray 
array works just fine, but both are slower than a list of tuples, and 
Numarray is MUCH slower. This appears to be exactly analogous the OP's 
example, of extracting a bunch of (2,) arrays from the (N,2) array. Then 
the two numbers must be extracted from the (2,) array, and then 
converted to a wxPoint. It seems the creation of all those (2,) 
numarrays is what's taking the time.

A) Is there work going on on speeding this up?

B) the real solution, at least for wxPython, is to make 
"PointListHelper" understand numarrays, so that it can go straight from 
the array->data pointer to the wxList of wxPoints. One of these days 
I'll get around to working on that!

-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