Skip to content

Commit f44242e

Browse files
author
irheart
committed
about_lists: pop(0) vs popleft() in 2vs3
I've looked for information on this note and haven't been able to find anything of the sort. A brief test in Py3.4.1 also indicates that list.pop(0) vs deque.popleft() performance in Py3 is consistent with Py2. >>> import timeit >>> timeit.timeit('''x = list(range(100000)) while x: x.pop(0) ''', number = 100) 385.9676046228002 >>> timeit.timeit('''x = deque(range(1000000)) while x: x.popleft() ''', setup = 'from collections import deque', number = 100) 17.6067819813139
1 parent 7708336 commit f44242e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

python3/koans/about_lists.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ def test_making_queues(self):
103103
self.assertEqual(__, popped_value)
104104
self.assertEqual(__, queue)
105105

106-
# Note, for Python 2 popping from the left hand side of a list is
106+
# Note, popping from the left hand side of a list is
107107
# inefficient. Use collections.deque instead.
108108

109-
# This is not an issue for Python 3 though
110-

0 commit comments

Comments
 (0)