On 1/16/2023 1:18 PM, Edmondo Giovannozzi wrote:

As a comparison with numpy. Given the following lines:

import numpy as np
a = np.random.randn(400,100_000)
ia = np.argsort(a[0,:])
a_elem = a[56, ia[0]]

I have just taken an element randomly in a numeric table of 400x100000 elements
To find it with numpy:

%timeit isel = a == a_elem
35.5 ms ± 2.79 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

And
%timeit a[isel]
9.18 ms ± 371 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

As data are not ordered it is searching it one by one but at C level.
Of course it depends on a lot of thing...

thank you for this. It's probably my lack of experience with Numpy, but... can you explain what is going on here in more detail?

Thank you

Dino
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to