Python style questions

Michael Hudson mwh21 at cam.ac.uk
Tue Mar 20 09:30:40 EST 2001


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/



More information about the Python-list mailing list