ChrisCScott / forecaster

A personal finances forecasting tool for Canadian retirement planning
Other
1 stars 2 forks source link

Memoize inflation_adjust #23

Open ChrisCScott opened 6 years ago

ChrisCScott commented 6 years ago

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)).