summaryrefslogtreecommitdiffstats
path: root/Lib/heapq.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-04-13 18:49:57 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-04-13 18:49:57 (GMT)
commit8a9c4d9866a29839e045bef51445085fe7938853 (patch)
treedae2c3c53283ae3d47a821bf949749e5c0cfe41d /Lib/heapq.py
parent5864c9f26c01d3a7eacc639c54f891d947f403f3 (diff)
downloadcpython-8a9c4d9866a29839e045bef51445085fe7938853.zip
cpython-8a9c4d9866a29839e045bef51445085fe7938853.tar.gz
cpython-8a9c4d9866a29839e045bef51445085fe7938853.tar.bz2
Issue 3051: make pure python code pass the same tests as the C version.
Diffstat (limited to 'Lib/heapq.py')
-rw-r--r--Lib/heapq.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/heapq.py b/Lib/heapq.py
index 464663a..3fe6b46 100644
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -212,11 +212,10 @@ def nsmallest(n, iterable):
pop = result.pop
los = result[-1] # los --> Largest of the nsmallest
for elem in it:
- if los <= elem:
- continue
- insort(result, elem)
- pop()
- los = result[-1]
+ if elem < los:
+ insort(result, elem)
+ pop()
+ los = result[-1]
return result
# An alternative approach manifests the whole iterable in memory but
# saves comparisons by heapifying all at once. Also, saves time