Paul Rubin <http://[EMAIL PROTECTED]> wrote:

> Unless the queue is really large, just use the pop operation to get
> stuff off the top of the queue.  That causes O(n) operations but it
> should be fast if n is small.
> 
>     class queue(list):
>         push = append
>         def pop(self):
>             return list.pop(self,0)
> 
> should do about what you wrote.

If it IS large, then:

import collections
class queue(collections.deque):
  push = collections.deque.append
  pop = collections.deque.popleft

could be even better.


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to