Code that ought to run fast, but can't due to Python limitations.
Paul Rubin
http
Sun Jul 5 05:54:23 EDT 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
form
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
mailing list