I just noticed that the zeros
function of numpy
has a strange behavior :
%timeit np.zeros((1000, 1000))
1.06 ms ± 29.8 μs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
%timeit np.zeros((5000, 5000))
4 μs ± 66 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
On the other hand, ones
seems to have a normal behavior.
Is anybody know why initializing a small numpy array with the zeros
function takes more time than for a large array ?
(Python 3.5, numpy 1.11)
See Question&Answers more detail:os