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
9f0ab9f5
Kaydet (Commit)
9f0ab9f5
authored
Nis 29, 2012
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Factor out shared variables.
üst
678e7f3b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
functools.py
Lib/functools.py
+6
-4
No files found.
Lib/functools.py
Dosyayı görüntüle @
9f0ab9f5
...
@@ -167,18 +167,20 @@ def lru_cache(maxsize=100, typed=False):
...
@@ -167,18 +167,20 @@ def lru_cache(maxsize=100, typed=False):
# The internals of the lru_cache are encapsulated for thread safety and
# The internals of the lru_cache are encapsulated for thread safety and
# to allow the implementation to change (including a possible C version).
# to allow the implementation to change (including a possible C version).
# Constants shared by all lru cache instances:
kwd_mark
=
(
object
(),)
# separate positional and keyword args
sentinel
=
object
()
# unique object used to signal cache misses
_len
=
len
# localize the global len() function
PREV
,
NEXT
,
KEY
,
RESULT
=
0
,
1
,
2
,
3
# names for the link fields
def
decorating_function
(
user_function
):
def
decorating_function
(
user_function
):
cache
=
{}
cache
=
{}
hits
=
misses
=
0
hits
=
misses
=
0
kwd_mark
=
(
object
(),)
# separate positional and keyword args
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
sentinel
=
object
()
# unique object used with cache_get
_len
=
len
# localize the global len() function
lock
=
Lock
()
# because linkedlist updates aren't threadsafe
lock
=
Lock
()
# 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
PREV
,
NEXT
,
KEY
,
RESULT
=
0
,
1
,
2
,
3
# names for the link fields
def
make_key
(
args
,
kwds
,
typed
,
tuple
=
tuple
,
sorted
=
sorted
,
type
=
type
):
def
make_key
(
args
,
kwds
,
typed
,
tuple
=
tuple
,
sorted
=
sorted
,
type
=
type
):
# build a cache key from positional and keyword args
# build a cache key from positional and keyword args
...
...
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