From 5c4e006367fcfb2cac3581080637976d0bd83921 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 16 Oct 2008 18:52:14 +0000 Subject: document that deque indexing is O(n) #4123 --- Doc/library/collections.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index a66b555..258b54f 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -247,7 +247,9 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin: In addition to the above, deques support iteration, pickling, ``len(d)``, ``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing with -the :keyword:`in` operator, and subscript references such as ``d[-1]``. +the :keyword:`in` operator, and subscript references such as ``d[-1]``. Indexed +access is O(1) at both ends but slows to O(n) in the middle. For fast random +access, use lists instead. Example: -- cgit v0.12