You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
heapq.nsmallest violates sorted equivalence for ordering-equivalent objects with identity equality #158718
Documented behaviour: The nsmallest docstring states: "Equivalent to: sorted(iterable, key=key)[:n]". Python's sorting documentation guarantees that sorts are stable.
Expected: ['e', 'a', 'b', 'c'], with exactly those object identities in that order
Activity
Link heapq-20261003-061723-c4 to python/cpython#158718
ZeroIntensity commentedon Oct 4, 2026
See #158748 (comment).