Create log message on Numba compilation / Find out if given arguments lead to compilation

You could do some hackish monkey patching

In [1]: import numba                                                                                                                                         

In [2]: oldcomp = numba.core.registry.CPUDispatcher.compile                                                                                                  

In [3]: def newcomp(*args, **kwargs): 
   ...:     print("I am compiling") 
   ...:     return oldcomp(*args, **kwargs) 
   ...:                                                                                                                                                      

In [4]: numba.core.registry.CPUDispatcher.compile = newcomp                                                                                                  

In [5]: @numba.njit 
   ...: def f(x): 
   ...:     return x 
   ...:                                                                                                                                                      

In [6]: f(1)                                                                                                                                                 
I am compiling
Out[6]: 1

In [7]: f(1.0)                                                                                                                                               
I am compiling
Out[7]: 1.0

In [8]: f(1.0)                                                                                                                                               
Out[8]: 1.0
1 Like