Nick Coghlan added the comment: On 4 December 2013 20:15, Radomir Dopieralski <rep...@bugs.python.org> wrote: > But I think it's would be still worthwhile to add a note to the lru_cache's > documentation, saying something like: > > """ > Warning! lru_cache will keep references to all the arguments for which it > keeps cached values, which prevents them from being freed from memory when > there are no other references. This can lead to memory leaks when you call a > function with lru_cache on a lot of short-lived objects. > """
Umm, that's part of the operational definition of a value based cache - it needs to keep things alive, so that if a different instance shows up with the same value, it will still get a cache hit. We're willing to put warnings in the docs for cases where it's easy to inadvertently introduce a security vulnerability, but not for situations like this where using a container inappropriately may cause it to keep objects alive that you didn't intend to keep alive. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19859> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com