metomi / isodatetime

:date: :watch: Python ISO 8601 date time parser and data model/manipulation utilities
GNU Lesser General Public License v3.0
37 stars 20 forks source link

Cache method calls #176

Open MetRonnie opened 4 years ago

MetRonnie commented 4 years ago

Follow on from #162

Now that the data classes have been made hashable, the next step is to implement some form of lru_cache for some of the methods.

I think we wouldn't implement it for the certain methods whose return value depends on e.g. whether the Duration is in weeks mode or normal mode, such as get_is_in_weeks() or __str__().

MetRonnie commented 2 years ago

I think we wouldn't implement it for the certain methods whose return value depends on e.g. whether the Duration is in weeks mode or normal mode, such as get_is_in_weeks() or __str__().

Actually, should be possible to do something like use a private helper method that accepts an arg is_in_weeks and cache that instead, then wrap that helper with the public method