On Sat, Jul 30, 2016, at 22:10, Steven D'Aprano wrote: > "while True" doesn't merely emulate an infinite loop, it implements an > infinite loop without needing dedicated syntax, byte-code or > implementation.
Er, it's not like it would need dedicated byte code anyway. The bytecode of an infinite loop is just an unconditional backward jump*, which we already have. The peephole optimizer already takes care of it (which _could_ be considered dedicated implementation; even if it's general enough to also work with "if True", how many of those do you figure there really are?) One argument that exists in favor of a dedicated infinite loop (and dedicated finite repetition loop) syntax, which I don't personally think applies to Python, is that the condition (and the whole construct for "for i in range", for finite repetitions) means additional concepts that have to be introduced at the same time to people being taught programming for the first time. *in fact, the bytecode of while already contains an unconditional backward jump; there's a conditional forward jump at the top - which is eliminated, I assume by the peephole optimizer, when the loop condition is a truthy constant. -- https://mail.python.org/mailman/listinfo/python-list