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
1f594ad4
Kaydet (Commit)
1f594ad4
authored
Agu 08, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
use same quoting as the rest of the file
üst
c41e1fad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
functools.py
Lib/functools.py
+6
-6
No files found.
Lib/functools.py
Dosyayı görüntüle @
1f594ad4
...
...
@@ -107,14 +107,14 @@ def cmp_to_key(mycmp):
return
K
def
lfu_cache
(
maxsize
=
100
):
'''
Least-frequently-used cache decorator.
"""
Least-frequently-used cache decorator.
Arguments to the cached function must be hashable.
Cache performance statistics stored in f.hits and f.misses.
Clear the cache using f.clear().
http://en.wikipedia.org/wiki/Cache_algorithms#Least-Frequently_Used
'''
"""
def
decorating_function
(
user_function
):
cache
=
{}
# mapping of args to results
use_count
=
Counter
()
# times each key has been accessed
...
...
@@ -142,7 +142,7 @@ def lfu_cache(maxsize=100):
return
result
def
clear
():
'Clear the cache and cache statistics'
"""Clear the cache and cache statistics"""
cache
.
clear
()
use_count
.
clear
()
wrapper
.
hits
=
wrapper
.
misses
=
0
...
...
@@ -153,14 +153,14 @@ def lfu_cache(maxsize=100):
return
decorating_function
def
lru_cache
(
maxsize
=
100
):
'''
Least-recently-used cache decorator.
"""
Least-recently-used cache decorator.
Arguments to the cached function must be hashable.
Cache performance statistics stored in f.hits and f.misses.
Clear the cache using f.clear().
http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
'''
"""
def
decorating_function
(
user_function
):
cache
=
OrderedDict
()
# ordered least recent to most recent
kwd_mark
=
object
()
# separate positional and keyword args
...
...
@@ -182,7 +182,7 @@ def lru_cache(maxsize=100):
return
result
def
clear
():
'Clear the cache and cache statistics'
"""Clear the cache and cache statistics"""
cache
.
clear
()
wrapper
.
hits
=
wrapper
.
misses
=
0
...
...
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