Maybe this is a case for Memoization
In computing, memoization is an optimization technique used primarily to speed up computer programs by having function calls avoid repeating the calculation of results for previously-processed inputs
The Memoize module makes it easy to use by wrapping around your function.
It might increase the memory footprint but make the processing faster so it better to benchmark it,and if you do use it afterall I would be interested in hearing the test results.
Memoization is not suitable for your project. I've read your question hasty and misinterpreted it