csu-hmc / opty

A library for using direct collocation in the optimization of dynamic systems.
http://opty.readthedocs.io
Other
86 stars 20 forks source link

Add ability to cache the "JIT" Cython compiled libraries #107

Open moorepants opened 10 months ago

moorepants commented 10 months ago

Once you have a model defined and correct, there is no reason to recompile it. Thus, it would be nice if the Cython compiled libraries are somehow cached. Opty can already write the files to disk, so we need some kind of check to know if the compiled library is the same as the one generated prior. We could do something like hash the sympy object that corresponds to the inputs to ufuncify_matrix and then store that string in the generated cython file. Once that is stored you could check for a match and skip the call to ufuncify_matrix.

I've seen this feature in Bjorn's https://github.com/bjodah/pycompilation.

moorepants commented 10 months ago

This example looks directly applicable: https://github.com/bjodah/pycompilation/blob/master/examples/on_the_fly_main.py