CPU usage of Python interpreter doing empty while loop under XP

Jon Perez jbperez808 at wahoo.com
Tue Apr 27 04:36:18 EDT 2004


Dennis Lee Bieber wrote:

> 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.

Great, it worked.

So 

while 1: sleep(0)

is a better alternative to

while 1: pass


(I'm using this for debugging purposes...)



More information about the Python-list mailing list