The rap against "while True:" loops

Bearophile bearophileHUGS at
Fri Oct 16 22:02:31 CEST 2009

Paul Rubin:

> Keep in mind that the article is 35 years old though, and is purely
> imperative.  Lots of stuff done with cockamamie looping constructs is
> more cleanly done with Python generators, itertools, higher-order
> functions, etc.

That's a famous and very good paper, a good read for people that like
to program.
The Example1 and Example2 can be rewritten in several different ways,
but several compilers today are not able to perform such optimizations
yet, so what Knuth has written there are still among the faster ways
to implement that algorithm.


More information about the Python-list mailing list