[issue19859] functools.lru_cache keeps objects alive forever

Radomir Dopieralski report at bugs.python.org
Wed Dec 4 00:57:43 CET 2013


Radomir Dopieralski added the comment:

Actually, after looking closer, my @memoize_method decorator does something completely different than Serhiy suggested. Still it only solves the common case of methods, and does nothing if you pass your short-lived objects as other parameters than self.

Limiting the cache size is also not a solution in the practical example with request that I linked to in the previous comment, because we can't know in advance how many times per request the function is going to be called, picking an arbitrary number feels wrong and may lead to unexpected behaviors when other fragments of code change (like a sudden slowdown every N calls).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19859>
_______________________________________


More information about the Python-bugs-list mailing list