John Nagle wrote: > Paul Rubin wrote: >> John Nagle <na...@animats.com> writes: >>> Python doesn't have a "switch" or "case" statement, and when >>> you need a state machine with many states, that makes for painful, >>> slow code. ... >>> There's a comment in the code that it would be useful >>> to run a few billion lines of HTML through an instrumented version >>> of the parser to decide in which order the IF statements should be >>> executed. You shouldn't have to do that. >> >> In that particular program it would probably be better to change those >> if/elif/elif/else constructs to dictionary lookups. I see the program >> already does that for some large tables. > > A dictionary lookup (actually, several of them) for every > input character is rather expensive.
Did you implement this and prove your claim in benchmarks? Taking a look at the current implementation, I'm pretty sure a dict-based implementation would outrun it in your first try. Stefan -- http://mail.python.org/mailman/listinfo/python-list