summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-03-21 09:37:54 (GMT)
committerGeorg Brandl <georg@python.org>2010-03-21 09:37:54 (GMT)
commita39f2afe9be7511bdb0d064dc5b14cf1ae4aa401 (patch)
tree3df68abc669b94ff104ed3c925c160450ef43c7a
parent0b56ce0bc49a8ac5536d5e06cf30f20b39631c13 (diff)
downloadcpython-a39f2afe9be7511bdb0d064dc5b14cf1ae4aa401.zip
cpython-a39f2afe9be7511bdb0d064dc5b14cf1ae4aa401.tar.gz
cpython-a39f2afe9be7511bdb0d064dc5b14cf1ae4aa401.tar.bz2
Mention inefficiency of lists as queues, add link to collections.deque discussion.
-rw-r--r--Doc/tutorial/datastructures.rst5
1 files changed, 5 insertions, 0 deletions
diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst
index a56fd2b..669dfc4 100644
--- a/Doc/tutorial/datastructures.rst
+++ b/Doc/tutorial/datastructures.rst
@@ -154,6 +154,11 @@ the queue, use :meth:`pop` with ``0`` as the index. For example::
>>> queue
['Michael', 'Terry', 'Graham']
+However, since lists are implemented as an array of elements, they are not the
+optimal data structure to use as a queue (the ``pop(0)`` needs to move all
+following elements). See :ref:`tut-list-tools` for a look at
+:class:`collections.deque`, which is designed to work efficiently as a queue.
+
.. _tut-functional: