Serhiy Storchaka added the comment: 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) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26194> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com