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
54da9819
Commit
54da9819
authored
Feb 19, 2007
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tie-breaker count to preserve sort stability.
parent
00166c55
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
Lib/heapq.py
Lib/heapq.py
+6
-6
No files found.
Lib/heapq.py
View file @
54da9819
...
...
@@ -323,10 +323,10 @@ def merge(*iterables):
h
=
[]
h_append
=
h
.
append
for
it
in
map
(
iter
,
iterables
):
for
it
num
,
it
in
enumerate
(
map
(
iter
,
iterables
)
):
try
:
next
=
it
.
next
h_append
([
next
(),
next
])
h_append
([
next
(),
itnum
,
next
])
except
_StopIteration
:
pass
heapify
(
h
)
...
...
@@ -334,12 +334,12 @@ def merge(*iterables):
while
1
:
try
:
while
1
:
v
,
next
=
s
=
h
[
0
]
# raises IndexError when h is empty
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
s
[
0
]
=
next
()
# raises StopIteration when exhausted
siftup
(
h
,
0
)
# restore heap condition
except
_StopIteration
:
_heappop
(
h
)
# remove empty iterator
_heappop
(
h
)
# remove empty iterator
except
IndexError
:
return
...
...
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