Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SortedKeyListoverrides__mul__, but inheritsSortedList.__rmul__. As a result, multiplying on the left drops the custom sort key:It can also raise
TypeErrorfor values such as dictionaries that require a key function to be ordered. BindSortedKeyList.__rmul__to its own__mul__, following the existing__radd__pattern, so both multiplication directions preserve the key.Add regression coverage for empty and nonempty inputs, negative/zero/positive counts, and dictionary values ordered by a custom key. The tests also verify that the original list is unchanged and repeated values retain their object identities.
Validation on Python 3.12 / Ubuntu 24.04:
pytest -q --tb=short: 375 passed, including the regression cases and doctests.doc8,rstcheck, Sphinx HTML build, package build, andtwine checkpass.B905diagnostics and formatting changes in two untouched files (docs/conf.pyandsrc/sortedcontainers/sorteddict.py). The same results were confirmed in a clean checkout of the base commit; this patch adds no new diagnostics.AI disclosure: This issue was identified during a code review, and the change was prepared and tested with OpenAI Codex.