Re: [Numpy-discussion] Improving performance of the `numpy.any` function.

2021-04-15 Thread zoj613
Although still much slower than the builtin `any`, this is an interesting and strange alternative way to improve the timing. My speeds are a result of using a _very_ old machine with a low-grade processor so maybe these times are more exaggerated to me than others. -- Sent from: http://numpy-dis

Re: [Numpy-discussion] Improving performance of the `numpy.any` function.

2021-04-15 Thread Sebastian Berg
On Wed, 2021-04-14 at 18:53 -0700, dan_patterson wrote: > a = np.zeros(1_000_000) > > a[100] = 1 > > %timeit np.any(a) > 814 µs ± 17.8 µs per loop (mean ± std. dev. of 7 runs, 1000 loops > each) > > %timeit np.any(a == 1) > 488 µs ± 5.68 µs per loop (mean ± std. dev. of 7 runs, 1000 loops > each

Re: [Numpy-discussion] Improving performance of the `numpy.any` function.

2021-04-14 Thread Brock Mendel
FWIW in https://github.com/pandas-dev/pandas/issues/32339 I tried short-circuiting (left == right).all() with a naive cython implementation. In the cases that _dont_ short-circuit, it was 2x slower than np.array_equal. On Wed, Apr 14, 2021 at 6:54 PM dan_patterson wrote: > a = np.zeros(1_000_000

Re: [Numpy-discussion] Improving performance of the `numpy.any` function.

2021-04-14 Thread dan_patterson
a = np.zeros(1_000_000) a[100] = 1 %timeit np.any(a) 814 µs ± 17.8 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) %timeit np.any(a == 1) 488 µs ± 5.68 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) Haven't investigated further since your times are much longer than mine and

[Numpy-discussion] Improving performance of the `numpy.any` function.

2021-04-14 Thread zoj613
Hi All, I was using numpy's `any` function earlier and realized that it might not be as performant as I assumed. See the code below: ``` In [1]: import numpy as np In [2]: a = np.zeros(1_000_000) In [3]: a[100] = 1 In [4]: b = np.zeros(2_000_000) In [5]: b[100] = 1 In [6]: %timeit np.any(a) 1