[issue3891] collections.deque should have empty() method

2008-09-20 Thread Raymond Hettinger
Raymond Hettinger <[EMAIL PROTECTED]> added the comment: Sorry Roy, I think you're way off base on this one. There are standard ways to test for an empty container "if c:" or "if len(c)" or "if len(c) > 0". This is Python 101. Closing this one as it has nothing to do specifically with collect

[issue3891] collections.deque should have empty() method

2008-09-19 Thread Roy Smith
Roy Smith <[EMAIL PROTECTED]> added the comment: I think you're missing the point. Imagine you are somebody who doesn't know Python internals. You're looking at the doc page for deque and ask yourself the question, "How do I tell if one of these is empty?". There's no information ON THAT PA

[issue3891] collections.deque should have empty() method

2008-09-19 Thread Terry J. Reedy
Terry J. Reedy <[EMAIL PROTECTED]> added the comment: I changed this to a doc issue for 2.6/3.0 whenever. I have two objections to adding "An empty deque evaluates as false". First, it implies (falsely) that it could be otherwise; since deque has no __bool__ method, its __len__ method is used,

[issue3891] collections.deque should have empty() method

2008-09-17 Thread Roy Smith
Roy Smith <[EMAIL PROTECTED]> added the comment: In retrospect, it's obvious that "while mydeque" is indeed the way to process the queue, yet, when I was reading the docs, I didn't come away with that. The statement, "list objects support similar operations", is wishy-washy. It is not the sa

[issue3891] collections.deque should have empty() method

2008-09-17 Thread Skip Montanaro
Skip Montanaro <[EMAIL PROTECTED]> added the comment: What would you suggest? The docs already say: Though list objects support similar operations, they are optimized for fast fixed-length operations and incur O(n) memory movement costs for pop(0) and insert(0, v) operations which change

[issue3891] collections.deque should have empty() method

2008-09-17 Thread Roy Smith
Roy Smith <[EMAIL PROTECTED]> added the comment: Sigh. It looks like you can do what I want after all, by just using the deque object itself, i.e.: q = deque() while (q): ... This should be changed to a docs bug -- the doc page for deque should mention this, or include an example of this

[issue3891] collections.deque should have empty() method

2008-09-17 Thread Roy Smith
Roy Smith <[EMAIL PROTECTED]> added the comment: I just realized my request may have been ambiguous; empty() is a predicate, not a verb. Doc should be something like: """Return true if the deque is empty. Return false otherwise.""" ___ Python tracker <[EMAI

[issue3891] collections.deque should have empty() method

2008-09-17 Thread Benjamin Peterson
Changes by Benjamin Peterson <[EMAIL PROTECTED]>: -- assignee: -> rhettinger components: +Extension Modules nosy: +rhettinger versions: +Python 2.7, Python 3.1 -Python 2.5 ___ Python tracker <[EMAIL PROTECTED]>

[issue3891] collections.deque should have empty() method

2008-09-17 Thread Roy Smith
New submission from Roy Smith <[EMAIL PROTECTED]>: Unless I'm missing something, the only way to tell if a deque is empty is to try and pop() something and catch the resulting IndexError. This is not only awkward, but mutates the data structure when you may not want to. It should be trivial t