Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 718ce2c

Browse files
committed
Merged revisions 79179 via svnmerge from
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. ........
1 parent 58bfdca commit 718ce2c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Doc/tutorial/datastructures.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ the queue, use :meth:`pop` with ``0`` as the index. For example::
153153
>>> queue
154154
['Michael', 'Terry', 'Graham']
155155

156+
However, since lists are implemented as an array of elements, they are not the
157+
optimal data structure to use as a queue (the ``pop(0)`` needs to move all
158+
following elements). See :ref:`tut-list-tools` for a look at
159+
:class:`collections.deque`, which is designed to work efficiently as a queue.
160+
156161

157162
.. _tut-listcomps:
158163

0 commit comments

Comments
 (0)