[Numpy-tickets] [NumPy] #595: sum function slow
NumPy
numpy-tickets@scipy....
Sun Oct 21 09:13:17 CDT 2007
#595: sum function slow
--------------------+-------------------------------------------------------
Reporter: Boris | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone:
Component: Other | Version: none
Severity: normal | Keywords:
--------------------+-------------------------------------------------------
Numpy's ''sum'' function is very slow for 1-D vectors (at least on my pc),
it is a lot faster to use e.g. the dot product with a ones vector (which
returns the same result):
{{{
t2 = Timer(setup='from numpy import *; c=1.*arange(1,1001)',
stmt='sum(c)')
t3 = Timer(setup='from numpy import *; c=1.*arange(1,1001)',
stmt='c.sum()')
t4 = Timer(setup='from numpy import *; c=1.*arange(1,1001); d=ones(1000)',
stmt='dot(c,d)')
t2.timeit(10000)
=0.204298445144
t3.timeit(10000)
=0.164432998837
t4.timeit(10000)
=0.0447709820354
}}}
My configuration:
Windows XP (Pentium D),
Numpy 1.0.3
--
Ticket URL: <http://scipy.org/scipy/numpy/ticket/595>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list