Message398716
I agree that composition is methodologically more correct than inheritance for implementing a variant of lru_cache(). But if you need lru_cache() why not use lru_cache() from the stdlib? I think that instead of showing a poor version of the lru_cache() decorator, it is better to show a tool which can be used for LRU caching. The key and the value should be evaluated externally. In other word, class LRU with methods __contains__(), __getitem__() and __setitem__() (or get() and set()). It should use composition.
Alternatively we can add a comment that it is just an example, and some methods (like pop()) can not work. |
|
Date |
User |
Action |
Args |
2021-08-01 17:19:51 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, docs@python, eric.snow, Dennis Sweeney, maximeLeurent |
2021-08-01 17:19:51 | serhiy.storchaka | set | messageid: <1627838391.88.0.61733891316.issue44782@roundup.psfhosted.org> |
2021-08-01 17:19:51 | serhiy.storchaka | link | issue44782 messages |
2021-08-01 17:19:51 | serhiy.storchaka | create | |
|