-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Open
Description
Brought up by this comment, it turns out that einsum
actually is another name for moveaxis, and is 10 times faster
a = np.zeros((10, 20, 30))
%timeit np.einsum('abc->cba', a)
2.24 µs ± 375 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
%timeit np.einsum(a, [0, 1, 2], [2, 1, 0])
2.65 µs ± 132 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
%timeit np.moveaxis(a, [0, 1, 2], [2, 1, 0])
22.1 µs ± 3.47 µs per loop (mean ± std. dev. of 7 runs, 100000 loops each)
Perhaps we should take advantage of this, especally since it would counteract the performance cost of #9475