bolorsociedad added the comment:
I understand it may be inefficient sometimes. Perhaps it would be nice to add
an argument to lru_cache to specify that we want to deep copy? Something like
def lru_cache(..., deepcopy=False):
...
--
___
Python
New submission from bolorsociedad :
The decorator functools.lru_cache seems to not work properly when the function
to be memoized returns a mutable object.
For instance:
>>> import functools
>>> @functools.lru_cache()
... def f(x):
...return [x, x + 1]
...
>>&g
Change by bolorsociedad :
--
components: Library (Lib)
nosy: bolorsociedad
priority: normal
severity: normal
status: open
title: Bug with memoization and mutable objects
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8