from dogpile.cache import make_region region = make_region().configure('dogpile.cache.memory') @region.cache_on_arguments() def foo(): return [1, 2, 3] def bar(): a = foo() a +=  return a print bar() print bar()
The first call to
[1, 2, 3, 4] as expected. However, the
 gets appended to the cached value (of type
list) in the dictionary for the cache. And the next call to
[1, 2, 3, 4, 4], which seems unexpected.
This would happen if the cached value is an object, so that the assignment in
bar() is assignment by reference.
Though this can be fixed by the user to clone the value, I think the memory backend may return a clone of the cached value instead of directly returning the value, which gives a chance that the cached value may get modified by the user. Also, from the perspective of abstraction, the user should not see a cached value being changed.