use same quoting as the rest of the file

This commit is contained in:
Benjamin Peterson 2010-08-08 13:17:07 +00:00
parent c41e1fad49
commit 1f594ad424
1 changed files with 6 additions and 6 deletions

View File

@ -107,14 +107,14 @@ def cmp_to_key(mycmp):
return K return K
def lfu_cache(maxsize=100): def lfu_cache(maxsize=100):
'''Least-frequently-used cache decorator. """Least-frequently-used cache decorator.
Arguments to the cached function must be hashable. Arguments to the cached function must be hashable.
Cache performance statistics stored in f.hits and f.misses. Cache performance statistics stored in f.hits and f.misses.
Clear the cache using f.clear(). Clear the cache using f.clear().
http://en.wikipedia.org/wiki/Cache_algorithms#Least-Frequently_Used http://en.wikipedia.org/wiki/Cache_algorithms#Least-Frequently_Used
''' """
def decorating_function(user_function): def decorating_function(user_function):
cache = {} # mapping of args to results cache = {} # mapping of args to results
use_count = Counter() # times each key has been accessed use_count = Counter() # times each key has been accessed
@ -142,7 +142,7 @@ def lfu_cache(maxsize=100):
return result return result
def clear(): def clear():
'Clear the cache and cache statistics' """Clear the cache and cache statistics"""
cache.clear() cache.clear()
use_count.clear() use_count.clear()
wrapper.hits = wrapper.misses = 0 wrapper.hits = wrapper.misses = 0
@ -153,14 +153,14 @@ def lfu_cache(maxsize=100):
return decorating_function return decorating_function
def lru_cache(maxsize=100): def lru_cache(maxsize=100):
'''Least-recently-used cache decorator. """Least-recently-used cache decorator.
Arguments to the cached function must be hashable. Arguments to the cached function must be hashable.
Cache performance statistics stored in f.hits and f.misses. Cache performance statistics stored in f.hits and f.misses.
Clear the cache using f.clear(). Clear the cache using f.clear().
http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
''' """
def decorating_function(user_function): def decorating_function(user_function):
cache = OrderedDict() # ordered least recent to most recent cache = OrderedDict() # ordered least recent to most recent
kwd_mark = object() # separate positional and keyword args kwd_mark = object() # separate positional and keyword args
@ -182,7 +182,7 @@ def lru_cache(maxsize=100):
return result return result
def clear(): def clear():
'Clear the cache and cache statistics' """Clear the cache and cache statistics"""
cache.clear() cache.clear()
wrapper.hits = wrapper.misses = 0 wrapper.hits = wrapper.misses = 0