A highly optimized double-ended queue for Go, significantly faster than container/list for adding/removing elements at both ends.
Deque is a Go library implementing a highly optimized double-ended queue data structure. It solves the performance limitations of Go's standard `container/list` package by providing significantly faster operations for adding and removing elements from both ends of the queue. The library includes a hardening feature for type safety and additional performance gains.
Go developers building performance-sensitive applications that require efficient queue operations, particularly those needing frequent additions and removals from both ends of a collection.
Developers choose Deque over alternatives because it offers benchmark-proven performance improvements (2-13x faster than container/list), memory efficiency with zero allocations in hardened mode, and a simple API while maintaining compatibility with Go's standard patterns.
A highly optimized double-ended queue
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Deque shows 2-13x faster operations than container/list in benchmarks, with push/pop times as low as 12 ns/op in hardened mode versus 158 ns/op for list.List.
In hardened mode, Deque achieves zero allocations per operation, reducing memory overhead and garbage collection pressure compared to standard libraries.
The hardening script allows compiling with a fixed element type, improving performance and catching type errors at compile time for safer code.
Offers intuitive methods like PushBack, PopFront, and Len that align with Go idioms, making it easy to adopt for developers used to container/list.
Achieving optimal performance requires running the hardening script, adding an extra step to the build process and potential toolchain dependencies.
Focuses solely on double-ended queue operations, lacking built-in support for concurrency, priority ordering, or efficient random access.
The recommendation to use v2 for generics introduces fragmentation, requiring Go 1.18+ and careful migration for older projects.