[issue25192] deque append and appendleft should return value if maxlen set

Raymond Hettinger report at bugs.python.org
Mon Sep 21 03:18:56 CEST 2015


Raymond Hettinger added the comment:

Sorry, Alun but I going to decline this feature request.  It has been considered before and that path wasn't taken for several reasons.  1) with the current api, it isn't hard to fetch the first value before appending, 2) in possible use cases such as a moving average computation it didn't make the code better (i.e. x==d[0]; d.append(y)), 3) list.append append is well known to alway return None (Guido considers that to be very informative about how the language works) so having deque.append return a value just looks weird to experienced Python programmers, and 4) it isn't entirely clear what the semantics should be if the deque hasn't yet reached its maximum length (it would be incorrect to assign None to x because that is a possible legitimate element of a deque and the alternative or raising an exception is also awkward, making it necessary to wrap append calls in a try/except).

----------
resolution:  -> rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25192>
_______________________________________


More information about the Python-bugs-list mailing list