acturtle / cashflower

An open-source Python framework for actuarial cash flow models
https://cashflower.acturtle.com
MIT License
38 stars 9 forks source link

Add caching to CSVReader class #326

Closed zchmielewska closed 1 year ago

zchmielewska commented 1 year ago

Let's say we've got mortality table with 100 ages and we have 100_000 model points.

The CSV reader has to (assuming uniform distribution) find the same value 1000 times.

So maybe it's worth to add caching to the CSV reader class to improve runtime?

zchmielewska commented 1 year ago

CSVReader keeps data as a defaultdict. Cache'ing would require also some kind of a dict so there is no really a point in that.

It would make sense if indeed we have a table with say 1000 values and we only use 10. But is that the case? I think not necessarily.

The trade-off is additional memory-usage for the cache. And the problem is that this memory is used during the model and not before. So I think let's pause this topic for now.