[Numpy-discussion] NumPy speed tests by NASA
pav at iki.fi
Tue Feb 22 16:54:45 EST 2011
On Tue, 22 Feb 2011 16:44:56 -0500, Alan G Isaac wrote:
> I don't believe the matrix multiplication results. Maybe I misunderstand
> them ...
> >>> t = timeit.Timer("np.dot(A,B)","import numpy as
> >>> np;N=1500;A=np.random.random((N,N));B=np.random.random((N,N))")
> >>> print t.timeit(number=10)/10.
> I'm using the precompiled Windows binaries.
... which are linked with BLAS. Compare:
In : A=np.ones((1000,1000))
In : B=np.ones((1000,1000))
In : %timeit np.dot(A, B)
1 loops, best of 3: 236 ms per loop
In : %timeit np.core.multiarray.dot(A, B)
1 loops, best of 3: 8.21 s per loop
If not BLAS is available at compile time, it falls back to using the
latter `dot` --- which is 35 x slower. The reason for the difference is
that the non-BLAS version can work also with object arrays etc. and so
does indirect function calls for the operations.
More information about the NumPy-Discussion