Skip to content

Commit

Permalink
Merged revisions 79179 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://[email protected]/python/trunk

........
  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.
........
  • Loading branch information
birkenfeld committed Mar 21, 2010
1 parent 58bfdca commit 718ce2c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Doc/tutorial/datastructures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 718ce2c

Please sign in to comment.