This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: O(1) deque indexing
Type: enhancement Stage: patch review
Components: Extension Modules Versions: Python 3.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-05-17 19:41 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
deque_array.patch serhiy.storchaka, 2016-05-17 19:41 review
Messages (2)
msg265773 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-17 19:41
Proposed patch changes the complexity of deque indexing from linear to constant. All other operations preserves its amortized cost.

New deque implementation use two-level array instead of linked list. Since free space is reserved at both side, new blocks can be added at both sides for constant time. Memory consumption is almost the same.
msg265798 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-05-18 01:51
Sorry Serhiy, I really don't want to do this.  Indexing is the least important part of the API and should not drive the overall structure.  This optimization is at odds with the design goal of a structure that is efficient at near end-points and is not intended to compete with lists which are supposed to be efficient for random access indexing.  The use cases for deques rarely use access by position anywhere are from the end-points, so in a way this is a false optimization that doesn't account for the intended use cases.  The core design has been stable for a very long time and I'm very happy with it as is.
History
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71234
2016-05-18 01:51:02rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg265798
2016-05-17 19:41:40serhiy.storchakacreate