New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
collections.deque should have empty() method #48141
Comments
Unless I'm missing something, the only way to tell if a deque is empty is It should be trivial to implement, and run in O(1) time. |
I just realized my request may have been ambiguous; empty() is a """Return true if the deque is empty. Return false otherwise.""" |
Sigh. It looks like you can do what I want after all, by just using the q = deque()
while (q):
... This should be changed to a docs bug -- the doc page for deque should |
What would you suggest? The docs already say:
for fast fixed-length operations and incur O(n) memory movement costs How would you suck elements out of a list? Probably with something while mylist:
elt = mylist.pop() Aside from possible performance issues it's not clear that you would use |
In retrospect, it's obvious that "while mydeque" is indeed the way to The statement, "list objects support similar operations", is wishy-washy. Anyway, to more concretely answer your question, I'd just make the plain |
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".
For 3.0, I suggest replacing "and empty strings..." with The sentence after next "User-defined objects can customize their truth
|
I think you're missing the point. Imagine you are somebody who doesn't know You give the page on boolean operations as part of the answer, but you need Essentially, what you're saying is that deque inherits some behaviors from Explicit is better than implicit :-) |
Sorry Roy, I think you're way off base on this one. There are standard
Closing this one as it has nothing to do specifically with |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: