Interact with python -- f2py or ctypes?

Hi @Dobrodzieju
Yes I have tried numba and I sometimes use it to speed up my python code.
But sometimes a function will be executed only once (but cost lot of time), then numba is not very suitable because it has to compile when I execute it for the first time.
I just knew that numba also offers AOT (ahead-of-time compilation) but I have not tested it.
Also sometimes I really need to speed up more – more than numba can offer. So I have to search for some method to call Fortran/C functions in python.

Still appreciate for your numba example! BTW, your numba version is much faster but I am curious about the performance when parallel is turned off?
(I don’t have a computer to test it now…)