Tuvas wrote: > I have a function in a program that works something like this. > > def load_pic_data(width,heigth,inpdat, filt=TRUE): > data='' > total=0 > tnum=0 > size=100 > for y in range(0,heigth): > row='' > for x in range(0,width): > index=2*(x+y*width) > num=ord(inpdat[index+1])*256+ord(inpdat[index]) > if(vfilter.get() and d_filter and filt): > num=round((num-(d_filter[index/2]))) > if(num<0): > num=0 > if(num>255*64): > num=255*64 > row=row+chr(num/64) > data=data+row > > The purpose of this part of a program is to take a 14 bit numerical > representation and convert it to an 8 bit representation. This will > later be displayed as an image. However, I've noticed the following > about this code. I was noticing when I took a small picture, it went > really fast, but a larger picture took forever to run through. I added > a print statement to the y portion of the code to see where it was > getting hung up. I noticed that it appears to be running slower as time > goes on.
hint: what does > row=row+chr(num/64) do, and how often is it executed ? </F> -- http://mail.python.org/mailman/listinfo/python-list