[Numpy-discussion] treating numpy arrays like lists is slow

Jeff Whitaker jswhit at fastmail.fm
Fri Feb 3 14:35:09 CST 2006


I've noticed that code like this is really slow in numpy (0.9.4):

import numpy as NP
a = NP.ones(10000,'d')
a = [2.*a1 for a1 in a]

the last line takes 0.17 seconds on my G5, while for Numeric and 
numarray it takes only 0.01.  Anyone know the reason for this?


Jeffrey S. Whitaker         Phone  : (303)497-6313
Meteorologist               FAX    : (303)497-6449
NOAA/OAR/PSD  R/PSD1        Email  : Jeffrey.S.Whitaker at noaa.gov
325 Broadway                Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg

More information about the Numpy-discussion mailing list