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
450ae573
Kaydet (Commit)
450ae573
authored
Haz 12, 2009
tarafından
Alexandre Vassalotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make pickling of OrderedDict instances more efficient.
üst
f0c9e46c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
collections.py
Lib/collections.py
+6
-4
test_collections.py
Lib/test/test_collections.py
+2
-2
No files found.
Lib/collections.py
Dosyayı görüntüle @
450ae573
...
...
@@ -99,14 +99,16 @@ class OrderedDict(dict, MutableMapping):
def
__reduce__
(
self
):
'Return state information for pickling'
items
=
[[
k
,
self
[
k
]]
for
k
in
self
]
dictitems
=
self
.
iteritems
()
tmp
=
self
.
__map
,
self
.
__root
del
self
.
__map
,
self
.
__root
inst_dict
=
vars
(
self
)
.
copy
()
self
.
__map
,
self
.
__root
=
tmp
if
inst_dict
:
return
(
self
.
__class__
,
(
items
,),
inst_dict
)
return
self
.
__class__
,
(
items
,)
# Set the state item to None when the dictionary is empty. This saves
# about 2 opcodes when the object is pickled.
if
not
inst_dict
:
inst_dict
=
None
return
(
self
.
__class__
,
(),
inst_dict
,
None
,
dictitems
)
setdefault
=
MutableMapping
.
setdefault
update
=
MutableMapping
.
update
...
...
Lib/test/test_collections.py
Dosyayı görüntüle @
450ae573
...
...
@@ -795,9 +795,9 @@ class TestOrderedDict(unittest.TestCase):
# do not save instance dictionary if not needed
pairs
=
[(
'c'
,
1
),
(
'b'
,
2
),
(
'a'
,
3
),
(
'd'
,
4
),
(
'e'
,
5
),
(
'f'
,
6
)]
od
=
OrderedDict
(
pairs
)
self
.
assertEqual
(
len
(
od
.
__reduce__
()),
2
)
od
.
x
=
10
self
.
assertEqual
(
len
(
od
.
__reduce__
()),
3
)
self
.
assertGreaterEqual
(
len
(
od
.
__reduce__
()),
2
)
self
.
assertLessEqual
(
len
(
od
.
__reduce__
()),
5
)
def
test_repr
(
self
):
od
=
OrderedDict
([(
'c'
,
1
),
(
'b'
,
2
),
(
'a'
,
3
),
(
'd'
,
4
),
(
'e'
,
5
),
(
'f'
,
6
)])
...
...
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