Tim Peters added the comment:

I'd raise an exception when trying to insert into a bounded deque that's 
already full.  There's simply no way to guess what was _intended_; it's dead 
easy for the user to implement what they _do_ intend (first make room by 
deleting the specific item they no longer want); and I can't think of a use 
case compelling enough to justify whatever arbitrary non-exceptional behavior 
may be implemented instead.

WRT the behavior you settled on, sure, it's explainable.  That doesn't imply 
it's useful, though ;-)  I'd rather have an exception.  It's plain bizarre that 
after

    d.insert(i, x)

one can't even rely on

    assert any(y is x for y in d)

succeeding.  Implementing behavior that allows that invariant to fail is 
_really_ user-unfriendly ;-)

In contrast, what .append() and .appendleft() do for a full bounded deque are 
compelling (and don't violate the weak invariant above).

----------

_______________________________________
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

Reply via email to