diff options
Diffstat (limited to 'ranger/ext/cached_function.py')
-rw-r--r-- | ranger/ext/cached_function.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/ranger/ext/cached_function.py b/ranger/ext/cached_function.py index ad7c5c11..daee6397 100644 --- a/ranger/ext/cached_function.py +++ b/ranger/ext/cached_function.py @@ -1,15 +1,15 @@ -# Copyright (C) 2012 Roman Zimbelmann <romanz@lavabit.com> +# Copyright (C) 2012-2013 Roman Zimbelmann <hut@lavabit.com> # This software is distributed under the terms of the GNU GPL version 3. def cached_function(fnc): - cache = {} - def inner_cached_function(*args): - try: - return cache[args] - except: - value = fnc(*args) - cache[args] = value - return value - inner_cached_function._cache = cache - return inner_cached_function + cache = {} + def inner_cached_function(*args): + try: + return cache[args] + except: + value = fnc(*args) + cache[args] = value + return value + inner_cached_function._cache = cache + return inner_cached_function |