I'm not sure what the advantages and disadvantages of these 2 are. Provided @lru_cache
from functools is a standard library tool and seems to have more control over @memoize
, why does @memoize
even exist?
Edit: I am referring to memoize from here -> https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize
functools.lru_cache
was added in python 3.2. For those using python 2, and for libraries written to work with it (e.g. all major libs) it cannot be used.
The workaround is to use the @memoize
recipe from the decorator library.
If you only use python 3, there is basically no reason not to use lru_cache
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With