]> granicus.if.org Git - python/commitdiff
Merge
authorRaymond Hettinger <python@rcn.com>
Fri, 1 Mar 2013 11:48:30 +0000 (03:48 -0800)
committerRaymond Hettinger <python@rcn.com>
Fri, 1 Mar 2013 11:48:30 +0000 (03:48 -0800)
1  2 
Lib/functools.py

index 2647f2da796e62142b15d22033b57490df30058a,71022e53c8f62c235dfadef20fba932a891f923a..c71d71420b1fd186e297904781578a2083e2c93f
  __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
  
  
  ################################################################################
@@@ -228,11 -202,12 +228,11 @@@ def lru_cache(maxsize=128, typed=False)
      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