[Python-checkins] cpython: Broaden the early-out test for nsmallest and nlargest
raymond.hettinger
python-checkins at python.org
Wed Mar 26 10:01:10 CET 2014
http://hg.python.org/cpython/rev/0f6c518183ef
changeset: 89982:0f6c518183ef
user: Raymond Hettinger <python at rcn.com>
date: Wed Mar 26 02:00:54 2014 -0700
summary:
Broaden the early-out test for nsmallest and nlargest
files:
Lib/heapq.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Lib/heapq.py b/Lib/heapq.py
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -197,7 +197,7 @@
Equivalent to: sorted(iterable, reverse=True)[:n]
"""
- if n < 0:
+ if n <= 0:
return []
it = iter(iterable)
result = list(islice(it, n))
@@ -215,7 +215,7 @@
Equivalent to: sorted(iterable)[:n]
"""
- if n < 0:
+ if n <= 0:
return []
it = iter(iterable)
result = list(islice(it, n))
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list