# Runtime specialization

**URL:** <https://numba.discourse.group/t/runtime-specialization/160>\
**Category:** Support: How do I do ...?\
**Created:** [August 6, 2020, 5:42pm UTC](https://numba.discourse.group/t/runtime-specialization/160 "2020-08-06T17:42:55Z")\
**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:** [August 7, 2020, 7:28am UTC](https://numba.discourse.group/t/runtime-specialization/160/2 "2020-08-07T07:28:49Z")

</div>

hi @gdonval, interesting question. I won’t claim to have an answer, but I’ll offer some ideas, hoping to learn from others’ replies.

My first thought is that if you want to get compile-time specialization, then you need to provide that information at compile-time. Not telling the compiler the shape of arr, and expecting it can optimize based on the unknown number, is probably hard.

A few ideas to get you closer to what you want.

- I’m curious why you need `loop_array_spec` to be jitted. Probably your real example is more complex, but `loop_array_spec` does not need to be jitted.

- I’m happy to treat pure python as a kind of macro system for jitted code, and I usually write things like:

- Similar to the above, there might be a way to use literal dispatching to do the tracking for you. I’m speculating here, I’m not sure exactly how to do it , but something like:

- I’m guessing you don’t have a huge number of possible array sizes, because if you had, specialization would spend a lot of time in compilation and possibly erase the benefits of faster runtime. so another idea is

I hope this helps, I’m curious to see what other people come up with.

Luk

---

_[View the full topic](https://numba.discourse.group/t/runtime-specialization/160)._
