Message259046
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). |
|
Date |
User |
Action |
Args |
2016-01-27 18:56:05 | tim.peters | set | recipients:
+ tim.peters, rhettinger, mark.dickinson, vstinner, python-dev, serhiy.storchaka |
2016-01-27 18:56:05 | tim.peters | set | messageid: <1453920965.54.0.103658001421.issue26194@psf.upfronthosting.co.za> |
2016-01-27 18:56:05 | tim.peters | link | issue26194 messages |
2016-01-27 18:56:05 | tim.peters | create | |
|