Search the archive

14,371 indexed articles, 13,299 of them summarised by us.

Articles
14,371
Research papers
91,965
Models priced
2,253
Providers
163

1 results for “collections.deque”

Newest and most relevant first

Beyond Lists: Using Python Deque for Real-Time Sliding Windows

Very little changes concretely: this is a tutorial arguing that Python's collections.deque beats lists for sliding windows and queues, but it provides no benchmarks, code, or numbers in the available text.

This is a how-to article about a built-in Python tool called deque (a 'double-ended queue', a structure that lets you quickly add or remove items at both ends). The author argues that using regular Python lists for sliding windows, keeping only the most recent items in a data stream, forces the computer to shift elements around, which is slow. The article does not include any benchmark numbers, code samples, or comparisons in the text available.

A Towards Data Science tutorial promotes Python's collections.deque as the right choice for sliding-window processing, thread-safe queues, and streaming data, claiming lists waste time shifting elements. The value is a technique swap rather than a product or announcement. No benchmarks, costs, or adoption data are provided in the available text.

The article argues that collections.deque provides O(1) appends and pops at both ends, making it superior to list.pop(0), which is O(n) due to element shifting, for real-time sliding windows and producer-consumer queues. It also cites thread-safety via append() and pop() being atomic. The preview text contains no code, no timing benchmarks, and no named alternatives beyond the list-versus-deque comparison.

Towards Data Science Blog →