Avoid recompilation of functions that take other functions as arguments

hi @hgrecco, I’ve been working on the topic of higher-order functions (e.g. Semantics of first-class functions) and I have the same question, which I posted on gitter last week (no answer yet).
I’m refining the proposal above, and I need to know whether there’s any performance advantage (like inlining) in re-compiling for every specific function being passed, which is the same question you have.

Regarding how to avoid it, I have created this PR (https://github.com/numba/numba/pull/5579), which would allow you to annotate step as receiving a function argument, and would avoid the duplicated compilation. Whether that’s desirable, it depends on whether there’s a performance advantage or not.

Thanks for posting, it’s good to know I’m not the only one having this problem.

Cheers,
Luk