[Numpy-discussion] matrix multiplication

Christopher Barker Chris.Barker@noaa....
Fri Jun 5 19:19:16 CDT 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?

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

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@noaa.gov


More information about the Numpy-discussion mailing list