__all__ = ['update_wrapper', 'wraps', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES',
'total_ordering', 'cmp_to_key', 'lru_cache', 'reduce', 'partial']
-from _functools import partial, reduce
+try:
+ from _functools import reduce
+except ImportError:
+ pass
from collections import namedtuple
try:
- from _thread import allocate_lock as Lock
+ from _thread import RLock
except:
- from _dummy_thread import allocate_lock as Lock
+ from dummy_threading import RLock
################################################################################
PREV, NEXT, KEY, RESULT = 0, 1, 2, 3 # names for the link fields
def decorating_function(user_function):
-
cache = {}
- hits = misses = currsize = 0
+ hits = misses = 0
full = False
cache_get = cache.get # bound method to lookup a key or return None
- lock = Lock() # because linkedlist updates aren't threadsafe
+ lock = RLock() # because linkedlist updates aren't threadsafe
root = [] # root of the circular doubly linked list
root[:] = [root, root, None, None] # initialize by pointing to self