Scenario produces an InflationAdjust object that gets called several times each year by various objects. Most of these calls use initial_year as base_year.
Cache the inflation adjustment factor for each year relative to initial_year. This can be done by using a memoization decorator on inflation_adjust or accumulation_function, or simply by building a dict at init time in Scenario (or InflationAdjust) such that d[year] is equivalent to accumulation_function(initial_year, year) (or inflation_adjust(year, initial_year)).
Scenario
produces anInflationAdjust
object that gets called several times each year by various objects. Most of these calls useinitial_year
asbase_year
.Cache the inflation adjustment factor for each year relative to
initial_year
. This can be done by using a memoization decorator oninflation_adjust
oraccumulation_function
, or simply by building a dict at init time inScenario
(orInflationAdjust
) such thatd[year]
is equivalent toaccumulation_function(initial_year, year)
(orinflation_adjust(year, initial_year)
).