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

This commit is contained in:
Georg Brandl 2010-03-21 09:37:54 +00:00
parent 0b56ce0bc4
commit a39f2afe9b
1 changed files with 5 additions and 0 deletions

View 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: