summaryrefslogtreecommitdiffstats
path: root/Lib/heapq.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-02-19 06:59:32 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-02-19 06:59:32 (GMT)
commit45eb0f141964bf59d20949fe82bea0af124d6854 (patch)
tree7244d025719aa6ca3be79391c6f5c4ba0e588b7e /Lib/heapq.py
parent54da9819cc74fe6091d090d12753116cfb6c6c62 (diff)
downloadcpython-45eb0f141964bf59d20949fe82bea0af124d6854.zip
cpython-45eb0f141964bf59d20949fe82bea0af124d6854.tar.gz
cpython-45eb0f141964bf59d20949fe82bea0af124d6854.tar.bz2
Use C heapreplace() instead of slower _siftup() in pure python.
Diffstat (limited to 'Lib/heapq.py')
-rw-r--r--Lib/heapq.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/heapq.py b/Lib/heapq.py
index 4c11eb6..5d41425 100644
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -319,7 +319,7 @@ def merge(*iterables):
[0, 1, 2, 3, 4, 5, 5, 7, 8, 10, 15, 20, 25]
'''
- _heappop, siftup, _StopIteration = heappop, _siftup, StopIteration
+ _heappop, _heapreplace, _StopIteration = heappop, heapreplace, StopIteration
h = []
h_append = h.append
@@ -337,7 +337,7 @@ def merge(*iterables):
v, itnum, next = s = h[0] # raises IndexError when h is empty
yield v
s[0] = next() # raises StopIteration when exhausted
- siftup(h, 0) # restore heap condition
+ _heapreplace(h, s) # restore heap condition
except _StopIteration:
_heappop(h) # remove empty iterator
except IndexError: