For a 1-D numpy array a, I thought that np.sum(a) and a.sum() are equivalent functions, but I just did a simple experiment, and it seems that the latter is always a bit faster:
In [1]: import numpy as np
In [2]: a = np.arange(10000)
In [3]: %timeit np.sum(a)
The slowest run took 16.85 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 6.46 µs per loop
In [4]: %timeit a.sum()
The slowest run took 19.80 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 5.25 µs per loop
Why is there a difference?
Does this mean that we should always use the numpy.ndarray version of functions like sum, mean, std, etc.?