[Python-Dev] An obscene computed goto bytecode hack for "switch" :)

Guido van Rossum guido at python.org
Sun Jun 18 20:23:32 CEST 2006


On 6/17/06, Armin Rigo <arigo at tunes.org> wrote:
> The reason is that the details of the stack behavior of END_FINALLY are
> messy in CPython.  The finally blocks are the only place where the depth
> of the stack is not known in advance: depending on how the finally block
> is entered, there will be between one and three objects pushed (a single
> None, or an int and another object, or an exception type, instance and
> traceback).

FWIW, I see this as an unintended accident and would gratefully accept
fixes to the bytecode that made this behavior more regular.

I'm not in favor of abusing this to generate a computed goto, and I
don't see a need for that -- if we decide to add that (either as
syntax or as an automatic optimization) I see no problem adding a new
bytecode. Python's bytecode is not sacred or frozen like Java's.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list