I use Python 3.6.1 and I use deque() from collections quite often due to its convenience. This time, I need to get the first value of a deque and wonder if it's possible.
The problem is that I can do that using .popleft()
, but it ends up deleting the value at the same time. I thought of list(deque01)[0]
, but I'm worried whether or not it's so much resource-consuming when deque01 is big or the process of getting the first value is repeated many times. Are there any methods or tricks to do this effectively?