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

fifo queue

2007-03-18 Thread drochom
hi, how would u improve this code? class queue: def __init__(self, size=8): self.space = size self.data = [None]*self.space self.head = 0 self.tail = 0 self.len = 0 def __len__(self): return self.len def push(self, x): if self.len==self.

Re: persistent fifo queue class

2007-03-08 Thread Diez B. Roggisch
David Bear schrieb: > Diez B. Roggisch wrote: > >> David Bear schrieb: >>> I'm looking to see if there are any examples or prewritting fifo queue >>> classes. I know this is a broad topic. I'm looking to implement a simple >>> application where a w

Re: persistent fifo queue class

2007-03-07 Thread Hendrik van Rooyen
"David Bear" <[EMAIL PROTECTED]> wrote: > Diez B. Roggisch wrote: > > Why don't you use a DB for that? If you want pickles, use a blob > > column. But all the rest - a defined protocol, stable server, > > transactions - you get for free. > > > > Diez > > Thanks for the suggestion. I did think o

Re: persistent fifo queue class

2007-03-07 Thread David Bear
Diez B. Roggisch wrote: > David Bear schrieb: >> I'm looking to see if there are any examples or prewritting fifo queue >> classes. I know this is a broad topic. I'm looking to implement a simple >> application where a web server enqueue and pickle using a local

Re: persistent fifo queue class

2007-03-06 Thread Diez B. Roggisch
David Bear schrieb: > I'm looking to see if there are any examples or prewritting fifo queue > classes. I know this is a broad topic. I'm looking to implement a simple > application where a web server enqueue and pickle using a local socket on > to a 'queue server'

persistent fifo queue class

2007-03-05 Thread David Bear
I'm looking to see if there are any examples or prewritting fifo queue classes. I know this is a broad topic. I'm looking to implement a simple application where a web server enqueue and pickle using a local socket on to a 'queue server' -- and then I will have another app