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
ac7c5acf
Kaydet (Commit)
ac7c5acf
authored
Ock 09, 2017
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge
üst
ce16c682
4ee39141
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
functools.py
Lib/functools.py
+3
-4
test_functools.py
Lib/test/test_functools.py
+10
-0
No files found.
Lib/functools.py
Dosyayı görüntüle @
ac7c5acf
...
@@ -421,7 +421,7 @@ class _HashedSeq(list):
...
@@ -421,7 +421,7 @@ class _HashedSeq(list):
def
_make_key
(
args
,
kwds
,
typed
,
def
_make_key
(
args
,
kwds
,
typed
,
kwd_mark
=
(
object
(),),
kwd_mark
=
(
object
(),),
fasttypes
=
{
int
,
str
,
frozenset
,
type
(
None
)},
fasttypes
=
{
int
,
str
,
frozenset
,
type
(
None
)},
sorted
=
sorted
,
tuple
=
tuple
,
type
=
type
,
len
=
len
):
tuple
=
tuple
,
type
=
type
,
len
=
len
):
"""Make a cache key from optionally typed positional and keyword arguments
"""Make a cache key from optionally typed positional and keyword arguments
The key is constructed in a way that is flat as possible rather than
The key is constructed in a way that is flat as possible rather than
...
@@ -434,14 +434,13 @@ def _make_key(args, kwds, typed,
...
@@ -434,14 +434,13 @@ def _make_key(args, kwds, typed,
"""
"""
key
=
args
key
=
args
if
kwds
:
if
kwds
:
sorted_items
=
sorted
(
kwds
.
items
())
key
+=
kwd_mark
key
+=
kwd_mark
for
item
in
sorted_items
:
for
item
in
kwds
.
items
()
:
key
+=
item
key
+=
item
if
typed
:
if
typed
:
key
+=
tuple
(
type
(
v
)
for
v
in
args
)
key
+=
tuple
(
type
(
v
)
for
v
in
args
)
if
kwds
:
if
kwds
:
key
+=
tuple
(
type
(
v
)
for
k
,
v
in
sorted_items
)
key
+=
tuple
(
type
(
v
)
for
v
in
kwds
.
values
()
)
elif
len
(
key
)
==
1
and
type
(
key
[
0
])
in
fasttypes
:
elif
len
(
key
)
==
1
and
type
(
key
[
0
])
in
fasttypes
:
return
key
[
0
]
return
key
[
0
]
return
_HashedSeq
(
key
)
return
_HashedSeq
(
key
)
...
...
Lib/test/test_functools.py
Dosyayı görüntüle @
ac7c5acf
...
@@ -1342,6 +1342,16 @@ class TestLRU:
...
@@ -1342,6 +1342,16 @@ class TestLRU:
self
.
assertEqual
(
fib
.
cache_info
(),
self
.
assertEqual
(
fib
.
cache_info
(),
self
.
module
.
_CacheInfo
(
hits
=
0
,
misses
=
0
,
maxsize
=
None
,
currsize
=
0
))
self
.
module
.
_CacheInfo
(
hits
=
0
,
misses
=
0
,
maxsize
=
None
,
currsize
=
0
))
def
test_kwargs_order
(
self
):
# PEP 468: Preserving Keyword Argument Order
@self.module.lru_cache
(
maxsize
=
10
)
def
f
(
**
kwargs
):
return
list
(
kwargs
.
items
())
self
.
assertEqual
(
f
(
a
=
1
,
b
=
2
),
[(
'a'
,
1
),
(
'b'
,
2
)])
self
.
assertEqual
(
f
(
b
=
2
,
a
=
1
),
[(
'b'
,
2
),
(
'a'
,
1
)])
self
.
assertEqual
(
f
.
cache_info
(),
self
.
module
.
_CacheInfo
(
hits
=
0
,
misses
=
2
,
maxsize
=
10
,
currsize
=
2
))
def
test_lru_cache_decoration
(
self
):
def
test_lru_cache_decoration
(
self
):
def
f
(
zomg
:
'zomg_annotation'
):
def
f
(
zomg
:
'zomg_annotation'
):
"""f doc string"""
"""f doc string"""
...
...
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