diff Doc/tutorial/datastructures.rst @ 59797:bc5e0d2e179d legacy-trunk

Mention inefficiency of lists as queues, add link to collections.deque discussion.
author Georg Brandl <georg@python.org>
date Sun, 21 Mar 2010 09:37:54 +0000
parents 7655142f5224
children 5e9eadc76e87
line wrap: on
line diff
--- a/Doc/tutorial/datastructures.rst	Sun Mar 21 09:28:16 2010 +0000
+++ b/Doc/tutorial/datastructures.rst	Sun Mar 21 09:37:54 2010 +0000
@@ -154,6 +154,11 @@
    >>> 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: