Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support mutable parameters #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pyfscache/fscache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
import base64
import inspect
import copy

__all__ = ["CacheError", "FSCache", "make_digest",
"auto_cache_function", "cache_function", "to_seconds"]
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down