Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to use collections.deque most effectively (popleft vs. appendleft)

$
0
0

I have been learning queues as I study data structures in Python and wanted to ask a question regarding its use.

I suppose there are two ways append/pop from a queue. First way would be to use deque.append() and deque.popleft(). Another way would be to use deque.appendleft() and deque.pop(). Is there a performance difference between the two? If not, which one is used more often from your experience? Do you recommend one over another for some other reason?

From my point of view, they essentially do the same thing as they both implement first-in-first-out. Your input would be much appreciated!


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>