
On 27 Jan 2016, at 1:10 pm, Sebastian Berg <sebastian@sipsolutions.net> wrote:
On Mi, 2016-01-27 at 11:19 +0000, Nadav Horesh wrote:
Why the dot function/method is slower than @ on python 3.5.1? Tested from the latest 1.11 maintenance branch.
The explanation I think is that you do not have a blas optimization. In which case the fallback mode is probably faster in the @ case (since it has SSE2 optimization by using einsum, while np.dot does not do that).
I am a bit confused now, as A @ c is just short for A.__matmul__(c) or equivalent to np.matmul(A,c), so why would these not use the optimised blas? Also, I am getting almost identical results on my Mac, yet I thought numpy would by default build against the VecLib optimised BLAS. If I build explicitly against ATLAS, I am actually seeing slightly slower results. But I also saw these kind of warnings on the first timeit runs: %timeit A.dot(c) The slowest run took 6.91 times longer than the fastest. This could mean that an intermediate result is being cached and when testing much larger arrays, the discrepancy between matmul and dot rather increases, so perhaps this is more an issue of a less memory-efficient implementation in np.dot? Cheers, Derek