[Numpy-discussion] Boolean arrays

Nathaniel Smith njs at pobox.com
Fri Aug 27 17:55:33 EDT 2010


On Fri, Aug 27, 2010 at 1:35 PM, Robert Kern <robert.kern at gmail.com> wrote:
> [~]
> |8> %timeit kern_in(ar, valid)
> 10 loops, best of 3: 115 ms per loop
>
> [~]
> |9> %timeit np.in1d(ar, valid)
> 1 loops, best of 3: 279 ms per loop
>
> As valid gets larger, in1d() will catch up but for smallish sizes of
> valid, which I suspect given the "non-numeric" nature of the OP's (Hi,
> Brett!) request, kern_in() is usually better.

Oh well, I was just guessing based on algorithmic properties. Sounds
like there might be some optimizations possible to in1d then, if
anyone had a reason to care :-).

-- Nathaniel



More information about the NumPy-Discussion mailing list