while 1 vs while True
danb_83 at yahoo.com
Mon Dec 13 02:59:25 CET 2004
Timothy Fitz wrote:
> [ http://www.python.org/moin/PythonSpeed ]
> "Starting with Py2.3, the interpreter optimizes 'while 1' to just a
> single jump. In contrast "while True" takes several more steps. While
> the latter is preferred for clarity, time-critical code should use
> first form."
> Out of pure curiousity,
> Why wasn't 'While True' optimized also?
Probably has something to do with "True" and "False" not being
>>> True = 0
>>> while True:
... print 'Not an infinite loop. In fact, it never executes at all.'
More information about the Python-list