Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
45eb0f14
Commit
45eb0f14
authored
Feb 19, 2007
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use C heapreplace() instead of slower _siftup() in pure python.
parent
54da9819
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
Lib/heapq.py
Lib/heapq.py
+2
-2
No files found.
Lib/heapq.py
View file @
45eb0f14
...
...
@@ -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
:
...
...
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