[Python] np.zeros becomes faster with a very large array size [duplicate]

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    %timeit -n 1000 -r 7 np.zeros(100000000, dtype=bool)


    gives 4.22 ms

    %timeit -n 1000 -r 7 np.zeros(1000000000, dtype=bool) # 1 more zero = 10 times longer array


    gives 3.13 μs (not even milliseconds, microseconds!?)

    How can this be possible? Is this hardware dependent?

    Continue reading...

Compartilhe esta Página