[Python-checkins] r79179 - python/trunk/Doc/tutorial/datastructures.rst

georg.brandl python-checkins at python.org
Sun Mar 21 10:37:54 CET 2010


Author: georg.brandl
Date: Sun Mar 21 10:37:54 2010
New Revision: 79179

Log:
Mention inefficiency of lists as queues, add link to collections.deque discussion.

Modified:
   python/trunk/Doc/tutorial/datastructures.rst

Modified: python/trunk/Doc/tutorial/datastructures.rst
==============================================================================
--- python/trunk/Doc/tutorial/datastructures.rst	(original)
+++ python/trunk/Doc/tutorial/datastructures.rst	Sun Mar 21 10:37:54 2010
@@ -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:
 


More information about the Python-checkins mailing list