Author serhiy.storchaka
Recipients Dennis Sweeney, docs@python, eric.snow, maximeLeurent, rhettinger, serhiy.storchaka
Date 2021-08-01.17:19:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627838391.88.0.61733891316.issue44782@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-08-01 17:19:51serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, docs@python, eric.snow, Dennis Sweeney, maximeLeurent
2021-08-01 17:19:51serhiy.storchakasetmessageid: <1627838391.88.0.61733891316.issue44782@roundup.psfhosted.org>
2021-08-01 17:19:51serhiy.storchakalinkissue44782 messages
2021-08-01 17:19:51serhiy.storchakacreate