An example with a 1-D array (where it is easiest to see what I mean) is the
following. I will follow Dom Grigonis's suggestion that the range not be
provided as a separate argument, as it can be just as easily "folded into"
the array by passing a slice. So it becomes just:
idx = first_true(arr, con
I juggled a bit and found pretty nice solution using numba. Which is probably
not very robust, but proves that such thing can be optimised while retaining
flexibility. Check if it works for your use cases and let me know if anything
fails or if it is slow compared to what you used.
first_true_s