Numba Jit auto cache vs on disk caching

Viewed 156

I've been looking for an answer in the numba docs, but I haven't been able to find anything.

The numba.jit decorator caches compiled functions automatically. Additionally, you can pass cache=True argument to it to create an on-disk cache.

What's the difference between both caching methods? Does on-disk cache persist, so that next time I execute my code, even on a "fresh" Ipython kernel, I can skip the compilation?

Thanks in advance!

1 Answers

A year and a half later, this question was a top result when I was looking for the same answer.

Looking in the code, I found the jit results are cached by default under __pycache__ on a function-by-function basis. I removed these and saw them repopulate when running the code again.

AFAIK the "automatic" caching you are referring to is just in memory, while the disk cache is of course on disk. The disk cache persists and is loaded next time you run your program, skipping the compilation as you said.

After delving into the sources, I did end up finding the answer in the docs, too. Looks like you can override the cache location using the NUMBA_CACHE_DIR environment variable.

Related