Message258996
New behavior looks less surprising to me.
Old behavior is even more weird for negative indices:
>>> from collections import deque
>>> d = deque(range(20), maxlen=10)
>>> d
deque([10, 11, 12, 13, 14, 15, 16, 17, 18, 19], maxlen=10)
>>> d.insert(-3, 'New')
>>> d
deque([11, 12, 13, 14, 15, 16, 'New', 18, 19, 10], maxlen=10)
Note that new element not just replaced the old one in the middle of the deque, but all context was rotated one position left.
Patched code behave less surprising.
>>> d.insert(-3, 'New')
>>> d
deque([10, 11, 12, 13, 14, 15, 'New', 16, 17, 18], maxlen=10) |
|
Date |
User |
Action |
Args |
2016-01-27 06:59:14 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, tim.peters, rhettinger, mark.dickinson, python-dev |
2016-01-27 06:59:14 | serhiy.storchaka | set | messageid: <1453877954.19.0.836103527316.issue26194@psf.upfronthosting.co.za> |
2016-01-27 06:59:14 | serhiy.storchaka | link | issue26194 messages |
2016-01-27 06:59:13 | serhiy.storchaka | create | |
|