Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
5fa40c01
Kaydet (Commit)
5fa40c01
authored
Kas 25, 2010
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Clean-up docstring, comments, and whitespace.
üst
99f9637d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
functools.py
Lib/functools.py
+15
-5
No files found.
Lib/functools.py
Dosyayı görüntüle @
5fa40c01
...
@@ -118,13 +118,22 @@ def lru_cache(maxsize=100):
...
@@ -118,13 +118,22 @@ 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.
Clear the cache using f.clear().
Performance statistics stored in f.cache_hits and f.cache_misses.
http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
Clear the cache and statistics using f.cache_clear().
The underlying function is stored in f.__wrapped__.
See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
"""
"""
def
decorating_function
(
user_function
,
tuple
=
tuple
,
sorted
=
sorted
,
# Users should only access the lru_cache through its public API:
len
=
len
,
KeyError
=
KeyError
):
# cache_hits, cache_misses, cache_clear(), and __wrapped__
# The internals of the lru_cache are encapsulated for thread safety and
# to allow the implementation to change (including a possible C version).
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
cache_popitem
=
cache
.
popitem
cache_popitem
=
cache
.
popitem
cache_renew
=
cache
.
move_to_end
cache_renew
=
cache
.
move_to_end
...
@@ -159,4 +168,5 @@ def lru_cache(maxsize=100):
...
@@ -159,4 +168,5 @@ def lru_cache(maxsize=100):
wrapper
.
cache_hits
=
wrapper
.
cache_misses
=
0
wrapper
.
cache_hits
=
wrapper
.
cache_misses
=
0
wrapper
.
cache_clear
=
cache_clear
wrapper
.
cache_clear
=
cache_clear
return
wrapper
return
wrapper
return
decorating_function
return
decorating_function
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