Commit Graph
1 Commits
Author SHA1 Message Date
Luan Taraschi c3d22bb225 Insert the item rather than its key in bisect.insort (#8565)
insort_left and insort_right rebound `x` to `key(x)` and then handed that
same value to both the search and `a.insert`, so the object the caller
passed in never reached the list:

    >>> words = ["a", "ccc"]
    >>> bisect.insort(words, "bb", key=len)
    >>> words
    ['a', 2, 'ccc']

The key now feeds the search only, and the insert keeps the original.

Assisted-by: Claude Code:claude-opus-5
2026-08-22 12:41:53 +09:00