Getting the outputted C code from a jitted function

Hi all,

I recently wrote the same script in Numba and C+CFFI. To my suprise Numba was five times faster than the C+CFFI implementation, and it seems like I’m not the only person to have encountered this phenomenon*. I assume the reason for the speed up is because Numba is highly optimised for Numpy and that I’m not very good at writing optimised C code.

Is it possible to output the C code from the jitted Numba function? I would love to compare this to my own C code to see where my failures are.

Thanks so much!

*unfortunately discourse isn’t letting me link to a post with a similar query to mine. For those interested, search on Google “numba vs c+cffi”.

Hi and thank you for asking about this. It will not be possible to do since Numba does not generate any C code. It does generate native assembly code though, which will be your best bet when trying to compare your implementation to what Numba generates. If you are interested, please checkout:

https://numba.pydata.org/numba-doc/latest/reference/jit-compilation.html#Dispatcher.inspect_asm

1 Like