]> granicus.if.org Git - python/commitdiff
Mention inefficiency of lists as queues, add link to collections.deque discussion.
authorGeorg Brandl <georg@python.org>
Sun, 21 Mar 2010 09:37:54 +0000 (09:37 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 21 Mar 2010 09:37:54 +0000 (09:37 +0000)
Doc/tutorial/datastructures.rst

index a56fd2b042af9c7ca8c79ef5539ca8451807abdd..669dfc465fe3718bd636046fe23501d0a3bcd97b 100644 (file)
@@ -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: