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
19c72385
Kaydet (Commit)
19c72385
authored
Ock 09, 2017
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Sync-up with 3.7 by backporting minor lru_cache code beautification
üst
4ee39141
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
functools.py
Lib/functools.py
+4
-3
No files found.
Lib/functools.py
Dosyayı görüntüle @
19c72385
...
@@ -492,6 +492,7 @@ def _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo):
...
@@ -492,6 +492,7 @@ def _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo):
hits
=
misses
=
0
hits
=
misses
=
0
full
=
False
full
=
False
cache_get
=
cache
.
get
# bound method to lookup a key or return None
cache_get
=
cache
.
get
# bound method to lookup a key or return None
cache_len
=
cache
.
__len__
# get cache size without calling len()
lock
=
RLock
()
# because linkedlist updates aren't threadsafe
lock
=
RLock
()
# because linkedlist updates aren't threadsafe
root
=
[]
# root of the circular doubly linked list
root
=
[]
# root of the circular doubly linked list
root
[:]
=
[
root
,
root
,
None
,
None
]
# initialize by pointing to self
root
[:]
=
[
root
,
root
,
None
,
None
]
# initialize by pointing to self
...
@@ -573,16 +574,16 @@ def _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo):
...
@@ -573,16 +574,16 @@ def _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo):
last
=
root
[
PREV
]
last
=
root
[
PREV
]
link
=
[
last
,
root
,
key
,
result
]
link
=
[
last
,
root
,
key
,
result
]
last
[
NEXT
]
=
root
[
PREV
]
=
cache
[
key
]
=
link
last
[
NEXT
]
=
root
[
PREV
]
=
cache
[
key
]
=
link
# Use the
__len__()
method instead of the len() function
# Use the
cache_len bound
method instead of the len() function
# which could potentially be wrapped in an lru_cache itself.
# which could potentially be wrapped in an lru_cache itself.
full
=
(
cache
.
__len__
()
>=
maxsize
)
full
=
(
cache
_len
()
>=
maxsize
)
misses
+=
1
misses
+=
1
return
result
return
result
def
cache_info
():
def
cache_info
():
"""Report cache statistics"""
"""Report cache statistics"""
with
lock
:
with
lock
:
return
_CacheInfo
(
hits
,
misses
,
maxsize
,
cache
.
__len__
())
return
_CacheInfo
(
hits
,
misses
,
maxsize
,
cache
_len
())
def
cache_clear
():
def
cache_clear
():
"""Clear the cache and cache statistics"""
"""Clear the cache and cache statistics"""
...
...
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