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
331722d4
Kaydet (Commit)
331722d4
authored
Eyl 02, 2010
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make OrderedDict.popitem() a bit smarter and faster
üst
19e5a6fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
collections.py
Lib/collections.py
+23
-11
No files found.
Lib/collections.py
Dosyayı görüntüle @
331722d4
...
...
@@ -108,25 +108,37 @@ class OrderedDict(dict, MutableMapping):
pass
dict
.
clear
(
self
)
setdefault
=
MutableMapping
.
setdefault
update
=
MutableMapping
.
update
pop
=
MutableMapping
.
pop
keys
=
MutableMapping
.
keys
values
=
MutableMapping
.
values
items
=
MutableMapping
.
items
__ne__
=
MutableMapping
.
__ne__
def
popitem
(
self
,
last
=
True
):
def
popitem
(
self
,
last
=
True
,
PREV
=
0
,
NEXT
=
1
,
KEY
=
2
,
dict_pop
=
dict
.
pop
):
'''od.popitem() -> (k, v), return and remove a (key, value) pair.
Pairs are returned in LIFO order if last is true or FIFO order if false.
'''
if
not
self
:
raise
KeyError
(
'dictionary is empty'
)
key
=
next
(
reversed
(
self
)
if
last
else
iter
(
self
))
value
=
self
.
pop
(
key
)
root
=
self
.
__root
if
last
:
# link_prev <--> link <--> root
link
=
root
[
PREV
]
link_prev
=
link
[
PREV
]
link_prev
[
NEXT
]
=
root
root
[
PREV
]
=
link_prev
else
:
# root <--> link <--> link_next
link
=
root
[
NEXT
]
link_next
=
link
[
NEXT
]
root
[
NEXT
]
=
link_next
link_next
[
PREV
]
=
root
key
=
link
[
KEY
]
del
self
.
__map
[
key
]
value
=
dict_pop
(
self
,
key
)
return
key
,
value
setdefault
=
MutableMapping
.
setdefault
update
=
MutableMapping
.
update
pop
=
MutableMapping
.
pop
keys
=
MutableMapping
.
keys
values
=
MutableMapping
.
values
items
=
MutableMapping
.
items
__ne__
=
MutableMapping
.
__ne__
def
__repr__
(
self
):
'od.__repr__() <==> repr(od)'
if
not
self
:
...
...
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