Python Bytecode

Michael Hudson mwh at python.net
Sat Aug 3 10:57:43 EDT 2002


"Terry Reedy" <tjreedy at udel.edu> writes:

> Can you or someone answer a question regarding the following from the
> above:
> "
> JUMP_IF_TRUE    delta
> If TOS is true, increment the byte code counter by delta. TOS is left
> on the stack.
> 
> JUMP_IF_FALSE    delta
> If TOS is false, increment the byte code counter by delta. TOS is not
> changed.
> "
> 
> Why isn't TOS removed?  

Haven't thought about this in a while, but I think it's for chained
comparisons, e.g. code like:

if 10 < a < 20:
    ...

> Or, at least, why isn't there alternative bytecode that does so?

Avoiding proliferation of opcodes?  Hard to say whether this would be
worth it without trying, and I'm unlikely to get around to trying it
soon...

> Seems like most (all?) usages remove it anyway on both branches.

Not quite all, I think.

Cheers,
M.

-- 
                    >> REVIEW OF THE YEAR, 2000 <<
                   It was shit. Give us another one.
                           -- NTK Now, 2000-12-29, http://www.ntk.net/



More information about the Python-list mailing list