Raymond Hettinger added the comment:
Serhiy is correct. In general, there is no way to detect when someone is
caching something that should be cached (i.e. impure functions).
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
Serhiy Storchaka added the comment:
No, this will break cases when you need to cache generators.
There are many ways of using lru_cache improperly, and we can't distinguish
incorrect uses from intentional correct uses.
--
assignee: -> rhettinger
nosy: +rhettinger, serhiy.storchaka
New submission from Michel Albert :
Consider the following code:
# filename: foo.py
from functools import lru_cache
@lru_cache(10)
def bar():
yield 10
yield 20
yield 30
# This loop will work as expected
for row in bar():
print(row)