I'm trying to speed up my scripts by using the numba module. However each time I run my script, numba
compile some of my classes (I use @jitclass
). I'm wondering if it is possible to compile my classes that I know they will not change in order to avoid having some time loss due to the compilation each time I run my script. I use numba
on a dozen of classes which take roughly 1 minute.
I've looked at compiling code ahead of time with numba
but I think I don't understand it well. link
However, as I use jitclass
I don't thing i can use that.
As far as I'm aware (current release of numba: 0.36), you cannot use jitclass
with ahead-of-time compilation (AOT).
It is unclear from your question how much compilation time is spent in your code. One minute seems extreme, but I've typically only used a few jitclasses
at a time. I have used dozens of inter-dependent functions spread across many modules and have never seen compilation times more than a handful of seconds.
If you could compare the time it takes to execute your code for the first time vs subsequent times, that should be the compilation time assuming the runtime is deterministic.
Your best option if the start up cost of doing just-in-time compilation is not practical is probably to use Cython to write C-extensions. The downside is that you won't be able to use them from numba code in nopython
mode. There many be some better way of organizing your datastructures that might help, but it's hard to tell without seeing the code.