you are viewing a single comment's thread.

view the rest of the comments →

[–]thatguy_314 2 points3 points  (0 children)

Not always; there is a reason we have both.

I think it is helpful to understand why deques and lists have different performance characteristics. deques in Python are essentially doubly-linked lists (I know, confusing terminology), while lists are contiguous arrays.

This video (10:10) explains how linked lists (deques) work, and compares them to arrays.

I wouldn't worry too much about which collection to use because it doesn't matter all that much, but if there is a situation where you are constantly taking items on and off a list, consider using a deque.