diff Lib/functools.py @ 66573:2b2fc4262170

Add example, tighten text, and minor clean-ups.
author Raymond Hettinger <python@rcn.com>
date Tue, 30 Nov 2010 19:15:45 +0000
parents f16bf4cae5d7
children 5cb53f094c1a
line wrap: on
line diff
--- a/Lib/functools.py	Tue Nov 30 17:49:53 2010 +0000
+++ b/Lib/functools.py	Tue Nov 30 19:15:45 2010 +0000
@@ -114,7 +114,7 @@
             raise TypeError('hash not implemented')
     return K
 
-_CacheInfo = namedtuple("CacheInfo", "maxsize, size, hits, misses")
+_CacheInfo = namedtuple("CacheInfo", "hits misses maxsize currsize")
 
 def lru_cache(maxsize=100):
     """Least-recently-used cache decorator.
@@ -166,7 +166,7 @@
         def cache_info():
             """Report cache statistics"""
             with lock:
-                return _CacheInfo(maxsize, len(cache), hits, misses)
+                return _CacheInfo(hits, misses, maxsize, len(cache))
 
         def cache_clear():
             """Clear the cache and cache statistics"""