mirror of
https://github.com/python/cpython.git
synced 2025-12-10 11:00:14 +00:00
Localize one more builtin lookup.
This commit is contained in:
parent
cbe8813f18
commit
5202fadb2c
1 changed files with 4 additions and 2 deletions
|
|
@ -119,7 +119,8 @@ def lfu_cache(maxsize=100):
|
||||||
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, tuple=tuple, sorted=sorted, len=len):
|
def decorating_function(user_function, tuple=tuple, sorted=sorted,
|
||||||
|
len=len, KeyError=KeyError):
|
||||||
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
|
||||||
kwd_mark = object() # separate positional and keyword args
|
kwd_mark = object() # separate positional and keyword args
|
||||||
|
|
@ -170,7 +171,8 @@ def lru_cache(maxsize=100):
|
||||||
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, tuple=tuple, sorted=sorted, len=len):
|
def decorating_function(user_function, tuple=tuple, sorted=sorted,
|
||||||
|
len=len, KeyError=KeyError):
|
||||||
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
|
||||||
lock = Lock()
|
lock = Lock()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue