[Numpy-discussion] Re: Function that searches arrays for the first element that satisfies a condition

2023-10-31 Thread Dom Grigonis
This results in a very slow code. The function calls of _pred = numba.njit(pred) are expensive and this sort of approach will be comparable to pure python functions. This is only recommended for sourcing functions that are not called frequently, but rather have a large computational content wit

[Numpy-discussion] Re: Function that searches arrays for the first element that satisfies a condition

2023-10-31 Thread Bill Ross
Could a sub-python level spin up extra threads (processes)? Search could benefit easily. I switched back to Java for number crunching because one gets to share memory without using OS-supplied shared memory. Maybe put a JVM behind python, or do python in the JVM? Bill -- Phobrain.com On 202

[Numpy-discussion] Re: Function that searches arrays for the first element that satisfies a condition

2023-10-31 Thread Juan Nunez-Iglesias
If you add a layer of indirection with Numba you can get a *very* nice API: @numba.njit def _first(arr, pred): for i, elem in enumerate(arr): if pred(elem): return i def first(arr, pred): _pred = numba.njit(pred) return _first(arr, _pred) This even works with lamb

[Numpy-discussion] Re: next NumPy Newcomers' Hour - 12pm UTC

2023-10-31 Thread Ganesh Kathiresan
Our next Newcomers' Hour will be held this Thursday, Nov 2nd, at 12pm UTC. Stop by to ask questions or just to say hi. To add to the meeting agenda the topics you’d like to discuss, follow the link: https://hackmd.io/3f3otyyuTte3FU9y3QzsLg?both Join the meeting via Zoom: https://us06web.zoom.us/j/8

[Numpy-discussion] Re: Function that searches arrays for the first element that satisfies a condition

2023-10-31 Thread Lev Maximov
I've implemented such functions in Cython and packaged them into a library called numpy_illustrated It exposes the following functions: find(a, v) # returns the index of the first occurrence of v in a first_above(a, v) # returns the index of the fi