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
8cd2e5f7
Kaydet (Commit)
8cd2e5f7
authored
May 05, 2011
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Sync-up minor code edits with the default branch.
üst
102d8749
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
functools.py
Lib/functools.py
+4
-4
No files found.
Lib/functools.py
Dosyayı görüntüle @
8cd2e5f7
...
@@ -97,7 +97,7 @@ def cmp_to_key(mycmp):
...
@@ -97,7 +97,7 @@ def cmp_to_key(mycmp):
"""Convert a cmp= function into a key= function"""
"""Convert a cmp= function into a key= function"""
class
K
(
object
):
class
K
(
object
):
__slots__
=
[
'obj'
]
__slots__
=
[
'obj'
]
def
__init__
(
self
,
obj
,
*
args
):
def
__init__
(
self
,
obj
):
self
.
obj
=
obj
self
.
obj
=
obj
def
__lt__
(
self
,
other
):
def
__lt__
(
self
,
other
):
return
mycmp
(
self
.
obj
,
other
.
obj
)
<
0
return
mycmp
(
self
.
obj
,
other
.
obj
)
<
0
...
@@ -140,7 +140,7 @@ def lru_cache(maxsize=100):
...
@@ -140,7 +140,7 @@ def lru_cache(maxsize=100):
tuple
=
tuple
,
sorted
=
sorted
,
len
=
len
,
KeyError
=
KeyError
):
tuple
=
tuple
,
sorted
=
sorted
,
len
=
len
,
KeyError
=
KeyError
):
hits
=
misses
=
0
hits
=
misses
=
0
kwd_mark
=
object
()
# separates positional and keyword args
kwd_mark
=
(
object
(),)
# separates positional and keyword args
lock
=
Lock
()
# needed because ordereddicts aren't threadsafe
lock
=
Lock
()
# needed because ordereddicts aren't threadsafe
if
maxsize
is
None
:
if
maxsize
is
None
:
...
@@ -151,7 +151,7 @@ def lru_cache(maxsize=100):
...
@@ -151,7 +151,7 @@ def lru_cache(maxsize=100):
nonlocal
hits
,
misses
nonlocal
hits
,
misses
key
=
args
key
=
args
if
kwds
:
if
kwds
:
key
+=
(
kwd_mark
,)
+
tuple
(
sorted
(
kwds
.
items
()))
key
+=
kwd_mark
+
tuple
(
sorted
(
kwds
.
items
()))
try
:
try
:
result
=
cache
[
key
]
result
=
cache
[
key
]
hits
+=
1
hits
+=
1
...
@@ -170,7 +170,7 @@ def lru_cache(maxsize=100):
...
@@ -170,7 +170,7 @@ def lru_cache(maxsize=100):
nonlocal
hits
,
misses
nonlocal
hits
,
misses
key
=
args
key
=
args
if
kwds
:
if
kwds
:
key
+=
(
kwd_mark
,)
+
tuple
(
sorted
(
kwds
.
items
()))
key
+=
kwd_mark
+
tuple
(
sorted
(
kwds
.
items
()))
try
:
try
:
with
lock
:
with
lock
:
result
=
cache
[
key
]
result
=
cache
[
key
]
...
...
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