ChrisCScott / forecaster

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

Making use of high-precision numeric types optional #78

Closed ChrisCScott closed 2 years ago

ChrisCScott commented 2 years ago

Dependence on Decimal has been eliminated for all classes. High-precision types are now optionally supported via high_precision arguments passed at init time and to most free methods.

This solution is not perfect. It requires client code to be careful about being consistent when passing numeric types - passing a float value as an argument to any one of numerous classes or methods is likely to raise an exception if high-precision types are also being used. It also clutters up the code by requiring that high_precision be passed around just about everywhere. It also (unnecessarily) converts int values to high-precision types.

Even so, this revision is an improvement - it works, has simplified testing considerably, and recognizes that native floating-point precision should generally be sufficient for this application.

In the long run, it is likely preferable to treat high-precision mode as a contextual setting, managed via contextvars, as suggested in this comment. But that can be left to a future issue.

Closes #77.