The current implementation of the functions in TidalPy relies on Numba's njit method which complies code at run-time. The resulting code is quite fast in many circumstances, especially when used alongside np.ndarrays. However, each time these functions are called they must be recompiled which can be quite slow. This tends not to be a problem for time studies which only need to compile once, but for static exploration (most of the Jupyter Notebooks) the compile times can be quite annoying.
In TidalPy v0.2.0, cacheable njit functions were introduced. These are only compiled once per unique call (where unique refers to the signature of the inputs, e.g., all floats, all arrays, some mix, etc.). They are then loaded from disk for subsequent calls. This can greatly increase the initial performance but does come at a small hit to run-time performance. There are also other issues with caching functions as mentioned in the "gotchas" documentation. Lastly, many of these functions should not change and do not need all of Python's overhead. There is no obvious reason they can not be pre-compiled using something like Cython.
Todo:
[ ] Look into Cython vs. raw C vs. Fortran (f2py) as options to write some lower level functions. What are the performance vs. compatibility benefits? What are the benefits vs. Numba (which is getting faster each day)?
[ ] If one of these approaches seems like a better option: how will they integrate in the OOP and functional scheme of TidalPy?
The current implementation of the functions in TidalPy relies on Numba's njit method which complies code at run-time. The resulting code is quite fast in many circumstances, especially when used alongside np.ndarrays. However, each time these functions are called they must be recompiled which can be quite slow. This tends not to be a problem for time studies which only need to compile once, but for static exploration (most of the Jupyter Notebooks) the compile times can be quite annoying.
In TidalPy v0.2.0, cacheable njit functions were introduced. These are only compiled once per unique call (where unique refers to the signature of the inputs, e.g., all floats, all arrays, some mix, etc.). They are then loaded from disk for subsequent calls. This can greatly increase the initial performance but does come at a small hit to run-time performance. There are also other issues with caching functions as mentioned in the "gotchas" documentation. Lastly, many of these functions should not change and do not need all of Python's overhead. There is no obvious reason they can not be pre-compiled using something like Cython.
Todo: