Re: time consuming loops over lists

2005-06-08 Thread Peter Otten
[EMAIL PROTECTED] wrote: > X-No-Archive: yes > Can some one help me improve this block of code...this jus converts the > list of data into tokens based on the range it falls into...but it > takes a long time.Can someone tell me what can i change to improve > it... > > def Tkz(tk,data): > no_

Re: time consuming loops over lists

2005-06-07 Thread Andrea Griffini
On Tue, 07 Jun 2005 23:38:29 +0200, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> I don't see a "break" so why the "/2" ? also IIUC the > >That was the assumption of an equal distribution of the data. In >O-notationn this would be O(n) of course. It was a joke ... the issue is that there was

Re: time consuming loops over lists

2005-06-07 Thread John Machin
Diez B. Roggisch wrote: > [EMAIL PROTECTED] wrote: > >> X-No-Archive: yes >> Can some one help me improve this block of code...this jus converts the >> list of data into tokens based on the range it falls into...but it >> takes a long time.Can someone tell me what can i change to improve >> it...

Re: time consuming loops over lists

2005-06-07 Thread Diez B. Roggisch
> I don't see a "break" so why the "/2" ? also IIUC the That was the assumption of an equal distribution of the data. In O-notationn this would be O(n) of course. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: time consuming loops over lists

2005-06-07 Thread Andrea Griffini
On Tue, 07 Jun 2005 18:13:01 +0200, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >Another optimization im too lazy now would be to do sort of a "tree >search" of data[i] in rngs - as the ranges are ordered, you could find >the proper one in log_2(len(rngs)) instead of len(rngs)/2. I don't see

Re: time consuming loops over lists

2005-06-07 Thread Peter Otten
[EMAIL PROTECTED] wrote: > Can some one help me improve this block of code...this jus converts the > list of data into tokens based on the range it falls into...but it > takes a long time.Can someone tell me what can i change to improve > it... > > def Tkz(tk,data): > no_of_bins = 10 >

Re: time consuming loops over lists

2005-06-07 Thread querypk
wow i dint know that a single statement like that would make such a difference. Thanks you very much. that really improves the performance -- http://mail.python.org/mailman/listinfo/python-list

Re: time consuming loops over lists

2005-06-07 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: X-No-Archive: yes Can some one help me improve this block of code...this jus converts the list of data into tokens based on the range it falls into...but it takes a long time.Can someone tell me what can i change to improve it... if data[i] in xrange(r

time consuming loops over lists

2005-06-07 Thread querypk
X-No-Archive: yes Can some one help me improve this block of code...this jus converts the list of data into tokens based on the range it falls into...but it takes a long time.Can someone tell me what can i change to improve it... def Tkz(tk,data): no_of_bins = 10 tkns = [] dmax = ma