Is there any way to compile model expressions a la numexpr?
Opened this issue · 3 comments
@DougBurke Do you mean in the python call?
I meant that
model1(energies=egrid, pars=pars1) * ( model2(energies=egrid, pars=pars2) + model3(energies=egrid, pars=pars3) )
has three places we jump from Python to C/C++. So, can we reduce as they discuss with the numexpr evaluate call?
I have no real experience with numexpr or numba, and no real idea of what would make sense - perhaps we just build up am expression of models to evaluate and the parameters they use and then evaluate that expression in C scope - so something like
model = model1(pars=pars1) * (model2(pars=pars2) + model3(pars=pars3))
y = model(energies=egrid)
but that's a lot of work compared to the current approach (and has its own usability issues...).
In my mind this is aspirational, but perhaps people have concrete advice or suggestions?
I have never been able to get this to work with f2py or python calls. I think there is a way with numba to link signatures which is what they do with scipy. So this maybe be the direction to go: https://github.com/numba/numba-scipy/blob/master/numba_scipy/special/signatures.py