How to let a loop run for a while before checking for break condition?
Diez B. Roggisch
deets at nospam.web.de
Sun Aug 27 08:42:52 EDT 2006
> The idea is to speed up a loop by using a timer interrupt interfering
> with the loop, so that only after the timer interrupt would occur, the
> loop will start to check its break condition in each iteration.
> No checking of any kind in the loop should happen up to that time to
> minimize the number of operations in each iteration within the loop
> itself (i.e. the loop more or less won't know, that there is a timer on
> its way to change the loops behavior at a later time).
A while loop has a condition. period. The only thing to change that is
to introduce a uncoditioned loop, and use self-modifying code to make it
a while-loop after that timer interrupt of yours.
But of course that whole thing is a moot point - if shaving mu-secs on
that level is needed for your application, use C or assembly instead.
Diez
More information about the Python-list
mailing list