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
secondly the equality check for 1 implies that perhaps a short circuit
actually exists somewhere 



--
Sent from: http://numpy-discussion.10968.n7.nabble.com/
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to