Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44782>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to