[Numpy-discussion] more speed?

Syrus Nemat-Nasser syrus at long.ucsd.edu
Thu Feb 17 18:27:29 EST 2000


On Thu, 17 Feb 2000, andrew x swan wrote:

> is this because the element by element
> calculations involved are contained in python for
> loops?

Hi Andrew!

I've only just begun using Numeric Python, but I'm a long-time user of GNU
Octave and a sporadic user of MatLab. In general, for loops kill the
execution speed of interpretive environments like Numpy and Octave. 

The high-speed comes when one uses vector operations such as Matrix
multiplication.

If you can vectorize your code, meaning replace all the loops with matrix
operations, you should see equivalent speed to Fortran for large data
sets. As far as I know, you will never see an interpreted language match a
compiled one in the execution of for loops.

Thanks. Syrus.

-- 

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Syrus Nemat-Nasser <syrus at ucsd.edu>    UCSD Physics Dept.






More information about the NumPy-Discussion mailing list