As suggested by @luk-f-a finding out if something got compiled is relatively easy, e.g.
from numba import njit
import numpy as np
def logging_jit(func):
def inner(*args, **kwargs):
origsigs = set(func.signatures)
result = func(*args, **kwargs)
newsigs = set(func.signatures)
if newsigs != origsigs:
new = (newsigs ^ origsigs).pop()
# PUT YOUR LOGGER HERE!
print("Numba compiled for signature: {}".format(new))
return result
return inner
@logging_jit
@njit
def foo(a):
return a + 1
print(foo(4)) # first compile and run for int
print(foo(5)) # second is just a run, int sig is cached
print(foo(6.7)) # third is a compile and run for float
finding out if something is going to be compiled is trickier but there are ways of doing that, it’ll involve producing Numba type signatures from the arguments and then comparing them to what’s already in the dispatcher’s cache.