[PyKDE] Huge amount of time

Christian Bird cbird at byu.edu
Wed Aug 20 21:33:00 BST 2003


One problem causing slowdown is that you're making a qt call over and over 
again that returns the same thing when you do self.verticalHeader().  Also, 
I'm not sure which is faster, but you could try doing string formatting 
instead of the hex(line_label)[2:].upper()).zfill(4) since that makes a bunch 
of function calls.  See if this sample code speeds things up at all (I 
haven't run it, but you should get the gist).



vh = self.verticalHeader()
for line_label in range(self.verticalHeader().count()):
	vh.setLabel(line_label, "#%04.x" % line_label)

That should run a little bit faster.

One other thing to try would be using xrange instead of range.  I'm not sure 
which one is faster, but I do know that xrange is more memory efficient.  
Hope that helps.

-- Chris

On Wednesday 20 August 2003 12:29 pm, Carlos Moreira wrote:
> Hello,
>
>      I have a very simple QTable with 65536 rows. I
> need to change the row labels to hex, I do this by
> using the code below:
>
> <code>
> for line_label in
> range(0,self.verticalHeader().count()):
>      self.verticalHeader().setLabel(line_label, "#" +
> (hex(line_label)[2:].upper()).zfill(4) )
> </code>
>
> But I need some help.....this simple code take a huge
> of time to change all row header labels. Is there some
> alternative to program this ?
>
>                Thanks
>
> Cadu
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde




More information about the PyQt mailing list