while 1 vs while True
Tue Dec 14 11:35:15 CET 2004
"Raymond Hettinger" <vze4rx4y at verizon.net> writes:
> It is unlike to before Py3.0. Making them constants would break the
> reams of compatability code: True, False = (1==1), (1!=1).
I don't see why that particular statement needs to fail. The
interpreter could permit assigning True=True or False=False without
raising an error. Then True and False wouldn't really be constants,
but they'd instead be variables whose value was always known to the
compiler, which for optimization purposes is just as good. The
compiler could alternatively do some simple dataflow analysis to make
sure the values of True and False haven't been changed in a particular
module, before doing that particular optimization.
More information about the Python-list