In a program where I store some dict
in a Queue.Queue
and I have to list each entry without removing them from the queue. Now I use this code snippet to iterate over the entries:
elements = Queue.Queue()
# populate the queue
for elem in list(elements.queue):
# print elem
In the code of Lib/Queue.py
and Lib/collections.py
I found that queue
is a proxy to deque
and in this answer of "Python: Queue.Queue vs. collections.deque" is mentioned not to use deque
directly.
Is there any particular reason not to use deque
? Hope someone can elaborate a little bit.