On 27 Apr 2004 04:45:21 GMT, "Jon Perez" <jbperez808@wahoo.com>
declaimed the following in comp.lang.python:
[color=blue]
> When you run an empty while loop under Python [with the
> interpreter at its default Normal Priority], it slows
> down the rest of the system. Is this normal? And should
> it be something that needs to be corrected?
>[/color]
Normal compared to what? The same loop in C? Assembly?
An empty loop would, to my mind, indicate that there are no OS
calls being made which could allow for a task switch. This would mean
that the entire time quantum will be used for that process, before a
forced OS preemption, followed by whatever other process you are
running. If that other process performs some sort of I/O (or other
system call) the odds are your empty loop will immediately regain
control.
And since a windowing system does LOTS of I/O, there is lots of
opportunity for the empty loop to suck down CPU cycles. Stick a
sleep(0) inside it, and no doubt you will see performance return to
"normal". Even though the 0 means no actual delay is wanted, the task
swap will occur, giving the OS a chance to respond to events.
--[color=blue]
> ================================================== ============ <
>
wlfraed@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
>
wulfraed@dm.net | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <[/color]