queue versus list

Barry barry at barrys-emacs.org
Fri Mar 20 17:57:42 EDT 2020



> On 20 Mar 2020, at 00:42, duncan smith <duncan at invalid.invalid> wrote:
> 
> Bingo. Performance is indistinguishable from that of the list. Thread
> safety is unimportant (for my purposes), but the docs at
> https://docs.python.org/2/library/collections.html#collections.deque
> state "Deques support thread-safe, memory efficient appends and pops
> from either side of the deque with approximately the same O(1)

I did a performance test of list vs sequel as a fifo that had 10k elements in them.
Then I timed insert elements at the tail and popping from the head.

Duque is 10x faster then list, rest run macOS python 3.8

Barry




More information about the Python-list mailing list