8 ms·
In the author's separate page of implementation notes, a Queue class is created that doesn't have threading overhead. That would be great, but it uses list.pop
by raymondh 12y ago
In the author's separate page of implementation notes, a Queue class is created that doesn't have threading overhead. That would be great, but it uses list.pop(0) which is an O(n) operation. For O(1) performance, it should use collections.deque.popleft() instead.
Otherwise, the article is first-rate :-)
- amitp 12y agoAh, thanks! I've been focusing on simplicity rather than performance, but deque is just as simple here, so I should use it. :-)