control structures (was "Re: Sins")
skaller
skaller at maxtal.com.au
Sat Jan 8 09:54:52 EST 2000
Skip Montanaro wrote:
>
> Darrell> Don't know if this if fair. But exceptions are slow when raised.
>
> Agreed in the case of your two-branch case. If you have a state machine
> with a bunch of states, try/except/except/... appears to perform about as
> well as if/elif/elif/.../else:
Yeah, but this is an artefact, since Python does not
have a proper switch statement. If/elif ... is clearly
linear time .. a switch is constant time. The Knuth
construction should support constant time loop exits,
as if it had been coded with gotos instead of breaks.
--
John (Max) Skaller, mailto:skaller at maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850
More information about the Python-list
mailing list