Code that ought to run fast, but can't due to Python limitations.
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sun Jul 5 05:13:23 EDT 2009
On Sun, 05 Jul 2009 01:58:13 -0700, Paul Rubin wrote:
> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
>> Okay, we get it. Parsing HTML 5 is a bitch. What's your point? I don't
>> see how a case statement would help you here: you're not dispatching on
>> a value, but running through a series of tests until one passes.
>
> A case statement switch(x):... into a bunch of constant case labels
> would be able to use x as an index into a jump vector, and/or do an
> unrolled logarithmic (bisection-like) search through the tests, instead
> of a linear search.
Yes, I'm aware of that, but that's not what John's code is doing -- he's
doing a series of if expr ... elif expr tests. I don't think a case
statement can do much to optimize that.
--
Steven
More information about the Python-list
mailing list