[Numpy-discussion] matrix multiplication

Christopher Barker Chris.Barker at noaa.gov
Fri Jun 5 20:19:16 EDT 2009

Robert Kern wrote:
>>>> x = np.array([1,2,3])
>>>> timeit x.sum()
>> 100000 loops, best of 3: 3.01 µs per loop
>>>> from numpy import sum
>>>> timeit sum(x)
>> 100000 loops, best of 3: 4.84 µs per loop

that is a VERY short array, so one extra function call overhead could 
make the difference. Is it really your use case to have such tiny sums 
inside a big loop, and is there no way to vectorize that?


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov

More information about the NumPy-Discussion mailing list