Re: fifo queue

2007-03-19 Thread Tim Roberts
"drochom" <[EMAIL PROTECTED]> wrote: > >how would u improve this code? I would add at least one comment... -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: fifo queue

2007-03-18 Thread Alex Martelli
Paul Rubin 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): >

Re: fifo queue

2007-03-18 Thread Roel Schroeven
drochom schreef: > hi, > > how would u improve this code? > > class queue: > ... I think I'd use collections.deque [1] instead of using a ring buffer as you're doing (I think) and doing a lot of manual bookkeeping. [1] http://docs.python.org/lib/deque-objects.html -- If I have been able t

Re: fifo queue

2007-03-18 Thread Paul Rubin
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 wr