How to let a loop run for a while before checking for break condition?

Fredrik Lundh fredrik at pythonware.com
Sun Aug 27 11:13:43 EDT 2006


Diez B. Roggisch wrote:

 > No doubt that changing the flag asynchronously is a gain by delegating
 > the timing code to the OS. Yet the while loop still has a condition -
 > you could as well set a flag in the signal handler an do it like this:

if the OP is obsessed with performance, why are you arguing that he 
"could as well" use a slower solution ?

> This is on my machine about 1.5 times slower than func1, but much more 
> readable 

polling a global state flag being "much more readable" than handling an 
exception in the usual way?  surely you're joking.

are you sure you're posted the code you're writing about, btw.  that "or 
True" looks a bit suspicious.

</F>




More information about the Python-list mailing list