[issue33827] Generators with lru_cache can be non-intuituve

2018-06-11 Thread Raymond Hettinger
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

[issue33827] Generators with lru_cache can be non-intuituve

2018-06-11 Thread Serhiy Storchaka
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

[issue33827] Generators with lru_cache can be non-intuituve

2018-06-11 Thread Michel Albert
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)