From 718ce2c2bd96910c09ed4ad7a2cfcd0b31720fe3 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 21 Mar 2010 09:51:44 +0000 Subject: [PATCH] Merged revisions 79179 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ........ r79179 | georg.brandl | 2010-03-21 10:37:54 +0100 (So, 21 Mär 2010) | 1 line Mention inefficiency of lists as queues, add link to collections.deque discussion. ........ --- Doc/tutorial/datastructures.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index ef364b20f84..8cf58c85b31 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -153,6 +153,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-listcomps: