|
From: Sasha <nd...@ma...> - 2006-02-03 23:10:43
|
This is so because scalar math is very slow in numpy. This will improve with the introduction of the scalarmath module. > python -m timeit -s "from numpy import float_; x =3D float_(2)" "2.*x" 100000 loops, best of 3: 15.8 usec per loop > python -m timeit -s "x =3D 2." "2.*x" 1000000 loops, best of 3: 0.261 usec per loop On 2/3/06, Jeff Whitaker <js...@fa...> wrote: > > Hi: > > I've noticed that code like this is really slow in numpy (0.9.4): > > import numpy as NP > a =3D NP.ones(10000,'d') > a =3D [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? > > -Jeff > > -- > Jeffrey S. Whitaker Phone : (303)497-6313 > Meteorologist FAX : (303)497-6449 > NOAA/OAR/PSD R/PSD1 Email : Jef...@no... > 325 Broadway Office : Skaggs Research Cntr 1D-124 > Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D103432&bid=3D230486&dat= =3D121642 > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |