Commit 811ef74
authored
Update 5.1.2. Using Lists as Queues in python tutorial
Apologies if the formatting for this pull request isn't correct.
In the description for 5.1.2. Using Lists as Queues, within the Data Structures section of the tutorial, the fact that appending and popping to the left of lists is inefficient is mentioned, and that one should instead use the deque object which was designed to have fast appends and pops from both ends.
But then in the example code we only have an example for how to remove elements from the left of the list and not add them. It's relatively straightforward that the method is appendleft(), but on first read I assumed that there was no implementation for this in the deque object as I didn't see it in the examples and it seemed to make intuitive sense that one shouldn't add elements to the start of queue.1 parent fca5529 commit 811ef74
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
191 | 194 | | |
192 | 195 | | |
193 | 196 | | |
| |||
0 commit comments