Don't wrap instance methods with 'functools.lru_cache' decorator in Python

from blog Redowan's Reflections, | ↗ original
Recently, fell into this trap as I wanted to speed up a slow instance method by caching it. When you decorate an instance method with functools.lru_cache decorator, the instances of the class encapsulating that method never get garbage collected within the lifetime of the process holding them. Let’s consider this example: # src.py import...