Python style questions
Jeremy R Van Haren
vanharen at cycletime.com
Fri Apr 6 03:40:50 EDT 2001
Michael Hudson wrote:
>
> Tim Roberts <timr at probo.com> writes:
>
> > Joshua Marshall <jmarshal at mathworks.com> wrote:
> > >
> > >A switch statement may just be syntactic sugar, but not necessarily in
> > >a simple way. A good compiler will compile switch statements into
> > >jump-tables or, at worst, binary searches. Cluttery to code by hand.
> > >
> > >Sure this is "just" an efficiency thing, but switches can get quite big.
> >
> > But Python, at least today, is not compiled.
>
> Yes it is (at least in this context).
>
> > Switch statements in an interpreted language are not as big of a
> > "win".
>
> There's no reason that the bytecode compiler couldn't do binary search
> jiggery-pokery, although if I was doing it, I'd probably use a
> dictionary.
>
> Cheers,
> M.
>
> --
> MGM will not get your whites whiter or your colors brighter.
> It will, however, sit there and look spiffy while sucking down
> a major honking wad of RAM. -- http://www.xiph.org/mgm/
Actually, switch "implementation" above that uses dictionary's which is
hashed. So a supported switch statement should be able to do hash as
well.
More information about the Python-list
mailing list