commit | 8f2420c94b350cf37b0ac06bda5539f754c1b469 | [log] [tgz] |
---|---|---|
author | Raymond Hettinger <python@rcn.com> | Wed Mar 26 02:00:54 2014 -0700 |
committer | Raymond Hettinger <python@rcn.com> | Wed Mar 26 02:00:54 2014 -0700 |
tree | 41a9441a4b315dbeaa4401d4e0d979573002a594 | |
parent | b0e69511936997810a1591a1e894910eaa44e3e3 [diff] [blame] |
Broaden the early-out test for nsmallest and nlargest
diff --git a/Lib/heapq.py b/Lib/heapq.py index d615239..d52cd71 100644 --- 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))