# Avoid recompilation of functions that take other functions as arguments

**URL:** <https://numba.discourse.group/t/avoid-recompilation-of-functions-that-take-other-functions-as-arguments/344>\
**Category:** Support: How do I do ...?\
**Created:** [November 16, 2020, 3:04pm UTC](https://numba.discourse.group/t/avoid-recompilation-of-functions-that-take-other-functions-as-arguments/344 "2020-11-16T15:04:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![luk-f-a](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/luk-f-a/32/56_2.png) [@luk-f-a](https://numba.discourse.group/u/luk-f-a)\
**Post date:** [November 16, 2020, 3:14pm UTC](https://numba.discourse.group/t/avoid-recompilation-of-functions-that-take-other-functions-as-arguments/344/2 "2020-11-16T15:14:21Z")

</div>

hi @hgrecco, I’ve been working on the topic of higher-order functions (e.g. [Semantics of first-class functions](https://numba.discourse.group/t/semantics-of-first-class-functions/323)) 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](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

---

_[View the full topic](https://numba.discourse.group/t/avoid-recompilation-of-functions-that-take-other-functions-as-arguments/344)._
