From 7f2856b8c3778af4f6769bc4a155f49a3a2b98e7 Mon Sep 17 00:00:00 2001 From: ophiry Date: Wed, 14 Oct 2015 08:45:45 +0300 Subject: [PATCH] support mutable parameters --- pyfscache/fscache.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyfscache/fscache.py b/pyfscache/fscache.py index 610c3bf..a7249cc 100755 --- a/pyfscache/fscache.py +++ b/pyfscache/fscache.py @@ -6,6 +6,7 @@ import time import base64 import inspect +import copy __all__ = ["CacheError", "FSCache", "make_digest", "auto_cache_function", "cache_function", "to_seconds"] @@ -425,7 +426,7 @@ def auto_cache_function(f, cache): except (AttributeError, TypeError): fid = (f.__name__, repr(type(f))) def _f(*args, **kwargs): - k = (fid, args, kwargs) + k = copy.deepcopy((fid, args, kwargs)) if k in cache: result = cache[k] else: @@ -447,7 +448,7 @@ def cache_function(f, keyer, cache): It is best to have a unique `keyer` for every function. """ def _f(*args, **kwargs): - k = keyer(*args, **kwargs) + k = copy.deepcopy(keyer(*args, **kwargs)) if k in cache: result = cache[k] else: