Code that ought to run fast, but can't due to Python limitations.
Sun Jul 5 11:54:23 CEST 2009
Stefan Behnel <stefan_ml at behnel.de> writes:
> > The series of tests is written that way because there is no case
> > statement available. It is essentially switching on a bunch of
> > character constants and then doing some additional tests in each
> > branch.
> Although doing some of the tests first and then checking the input
> conditionally might be faster here.
That is essentially what happens. There are a bunch of tests of the
if data=='<' and [some other stuff]: ...
Because of short-circuit evaluation of "and", the additional tests
only happen once the character has been matched.
More information about the Python-list