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
bd171bcf
Kaydet (Commit)
bd171bcf
authored
Şub 21, 2009
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Port r69838: Speedup and simplify negative counter using count's new step argument.
üst
934896dc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
heapq.py
Lib/heapq.py
+3
-3
No files found.
Lib/heapq.py
Dosyayı görüntüle @
bd171bcf
...
...
@@ -130,7 +130,7 @@ __all__ = ['heappush', 'heappop', 'heapify', 'heapreplace', 'merge',
'nlargest'
,
'nsmallest'
,
'heappushpop'
]
from
itertools
import
islice
,
repeat
,
count
,
tee
,
chain
from
operator
import
itemgetter
,
neg
from
operator
import
itemgetter
import
bisect
def
heappush
(
heap
,
item
):
...
...
@@ -413,13 +413,13 @@ def nlargest(n, iterable, key=None):
# When key is none, use simpler decoration
if
key
is
None
:
it
=
zip
(
iterable
,
map
(
neg
,
count
()))
# decorate
it
=
zip
(
iterable
,
count
(
0
,
-
1
))
# decorate
result
=
_nlargest
(
n
,
it
)
return
list
(
map
(
itemgetter
(
0
),
result
))
# undecorate
# General case, slowest method
in1
,
in2
=
tee
(
iterable
)
it
=
zip
(
map
(
key
,
in1
),
map
(
neg
,
count
()),
in2
)
# decorate
it
=
zip
(
map
(
key
,
in1
),
count
(
0
,
-
1
),
in2
)
# decorate
result
=
_nlargest
(
n
,
it
)
return
list
(
map
(
itemgetter
(
2
),
result
))
# undecorate
...
...
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