Skip to content

Commit c6742d7

Browse files
ybungalobillYakov Galka
andauthored
Fix stable sort in heapq.merge: python uses both __eq__ and __lt__ to… (#112)
* Fix stable sort in heapq.merge: python uses both __eq__ and __lt__ to compare tuples. Co-authored-by: Yakov Galka <[email protected]>
1 parent 5635ded commit c6742d7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

asyncstdlib/heapq.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ async def pull_head(self) -> bool:
9999
def __lt__(self, other: "_KeyIter[LT]") -> bool:
100100
return self.reverse ^ (self.head_key < other.head_key)
101101

102+
def __eq__(self, other: "_KeyIter[LT]") -> bool: # type: ignore[override]
103+
return not (self.head_key < other.head_key or other.head_key < self.head_key)
104+
102105

103106
@overload
104107
def merge(

0 commit comments

Comments
 (0)