Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5202fadb
Commit
5202fadb
authored
Aug 14, 2010
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Localize one more builtin lookup.
parent
cbe8813f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
Lib/functools.py
Lib/functools.py
+4
-2
No files found.
Lib/functools.py
View file @
5202fadb
...
@@ -119,7 +119,8 @@ def lfu_cache(maxsize=100):
...
@@ -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):
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment