python-sortedcontainers
python-sortedcontainers copied to clipboard
Feature request: update element key
trafficstars
For SortedKeyList, it would be nice to have a more optimized way of updating an item's key than doing remove + add.
A few things that come to mind would be:
- determining whether there is no position change and in that case do nothing
- searching only maxes before/after the changed element for the new insertion point
- avoiding list shrinking and enlargement if the element will end up in the same sublist
These are good ideas and I’ve thought about it before. Can you propose an API as one or more methods to support?