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
385c8036
Kaydet (Commit)
385c8036
authored
Eki 30, 2011
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge
üst
75861df9
e584457e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
heapq.py
Lib/heapq.py
+4
-0
No files found.
Lib/heapq.py
Dosyayı görüntüle @
385c8036
...
@@ -185,6 +185,8 @@ def nlargest(n, iterable):
...
@@ -185,6 +185,8 @@ def nlargest(n, iterable):
Equivalent to: sorted(iterable, reverse=True)[:n]
Equivalent to: sorted(iterable, reverse=True)[:n]
"""
"""
if
n
<
0
:
return
[]
it
=
iter
(
iterable
)
it
=
iter
(
iterable
)
result
=
list
(
islice
(
it
,
n
))
result
=
list
(
islice
(
it
,
n
))
if
not
result
:
if
not
result
:
...
@@ -201,6 +203,8 @@ def nsmallest(n, iterable):
...
@@ -201,6 +203,8 @@ def nsmallest(n, iterable):
Equivalent to: sorted(iterable)[:n]
Equivalent to: sorted(iterable)[:n]
"""
"""
if
n
<
0
:
return
[]
if
hasattr
(
iterable
,
'__len__'
)
and
n
*
10
<=
len
(
iterable
):
if
hasattr
(
iterable
,
'__len__'
)
and
n
*
10
<=
len
(
iterable
):
# For smaller values of n, the bisect method is faster than a minheap.
# For smaller values of n, the bisect method is faster than a minheap.
# It is also memory efficient, consuming only n elements of space.
# It is also memory efficient, consuming only n elements of space.
...
...
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