Closed TorkelE closed 5 months ago
We can't really cache the functions since doing so is type-unstable. Whenever a function is retrieved from the cache, it is inferred as Any
(or at best Function
) and calling it is slow. In general, if users cache the getu
functions they need in an appropriately typed data structure, it will be significantly faster.
Got it. Don't really understand, but if it's been considered then all good.
If you want to access say variables from a ODE solution, you can either:
gx = getu(sol, X)
followed bysol[gx]
.sol[X]
With the first being more performant if you want to make the access a very large number of times. It depends on how much space it take, but would it make sense to store
getu(sol, X)
insol
the first timesol[X]
is called? The subsequent callsol[X]
would have the same performance boost?sol
could have a field which is empty to store these structures until they are required. Not sure how much space thesegetu
functions take up, but figured it might be something to at least consider.