This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients josh.r, mark.dickinson, python-dev, rhettinger, serhiy.storchaka, tim.peters, vstinner
Date 2016-01-28.19:59:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1454011169.42.0.331742937873.issue26194@psf.upfronthosting.co.za>
In-reply-to
Content
Since slicing is going to be added to deques, it is worth thinking about what the behavior should be there as well:

   d = deque('abcde', maxlen=7)
   d[3:4] = 'efghijklm'

Side note: repetition behaves like extend() using maxlen to decide how much to truncate from the left:

    >>> from collections import deque
    >>> d = deque('abcde', maxlen=8)
    >>> d *= 2
    >>> d
    deque(['c', 'd', 'e', 'a', 'b', 'c', 'd', 'e'], maxlen=8)

Ideally, the deque API should be coherent and simple taken as a whole so that the behaviors are consistent and predictable as possible even if the general rules lead to some oddities in some uncommon cases.  

One such general rule could be:  "When maxlen is defined, operations proceed as if the deque were unbounded and then truncation is applied to the left" (this is like the rule in decimal where inputs to operations are treated as precise and context rounding is applied after the operation).  The general rule would fit a mental models of "inserted new data is prioritized over old data", that "maxlen is all about automatically evicting data to make room for the newer data", and that "methods without 'left' in their name correspond to newest data on the right and next to be evicted on the left".
History
Date User Action Args
2016-01-28 19:59:29rhettingersetrecipients: + rhettinger, tim.peters, mark.dickinson, vstinner, python-dev, serhiy.storchaka, josh.r
2016-01-28 19:59:29rhettingersetmessageid: <1454011169.42.0.331742937873.issue26194@psf.upfronthosting.co.za>
2016-01-28 19:59:29rhettingerlinkissue26194 messages
2016-01-28 19:59:29rhettingercreate