Opened 6 years ago

Closed 6 years ago

#6359 enhancement closed duplicate (duplicate)

DeferredQueue should use collections.deque instead of list

Reported by: mbeyer Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:


Deques support thread-safe, memory efficient appends and pops from either side of the deque with approximately the same O(1) performance in either direction.

Though list objects support similar operations, they are optimized for fast fixed-length operations and incur O(n) memory movement costs for pop(0) and insert(0, v) operations which change both the size and position of the underlying data representation.

Since the above covers all of the DeferredQueue list uses, collections.deque seem to be the better choice for holding the waiting/pending items of a DeferredQueue.

Change History (1)

comment:1 Changed 6 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: newclosed

Thanks for your interest in Twisted and DeferredQueue in particular. This issue has been filed already - it is #5628. Please take a look there if you'd like to contribute a patch! Thanks again.

Note: See TracTickets for help on using tickets.