General Numerical Python question

Michael Ressler ressler at cheetah.jpl.nasa.gov
Mon Oct 13 12:27:46 EDT 2003


In article <IGeib.271047$R32.8825532 at news2.tin.it>, Alex Martelli wrote:
> 2mc wrote:
> 
>> Generally speaking, if one had a list (from regular Python) and an
>> array (from Numerical Python) that contained the same number of
>> elements, would a While loop or a For loop process them at the same
>> speed?  Or, would the array process faster?
>> 
>> I'm new to Python, so my question may expose my ignorance.  I
>> appreciate anyone's effort to help me understand.
> 
> I don't know, I've never measured.  Let's find out together.

The real question is - why do you want to run a loop over an array?
The whole point of Numeric is that you want to eliminate loops
entirely. Keeping things in the array domain is infinitely faster than
running explicit loops. You may need to come up with some clever
expressions to do it, but most loops can be gotten rid of with clever
uses of put(), take(), and the like.

Loops are evil.

Mike

-- 
Dr. Michael Ressler
Research Scientist, Astrophysics Research Element, Jet Propulsion Laboratory
Email: ressler at cheetah.jpl.nasa.gov      Phone: (818)354-5576
"A bad night at the telescope is still better than the best day at the office."




More information about the Python-list mailing list