bytecode JUMP_IF_* always followed by POP_TOP?
Michael Hudson
mwh at python.net
Fri Apr 23 06:32:35 EDT 2004
"Robert Brewer" <fumanchu at amor.org> writes:
> Tim Peters wrote:
> > [Robert Brewer]
> > > Playing around with bytecodes some more:
> > > ...
> > > I notice that, whether JUMP_IF_FALSE jumps or not, the next
> > > instruction it executes is POP_TOP
> > > ...
> > > Are there any constructions whereby this does not happen for
> > > JUMP_IF_FALSE and JUMP_IF_TRUE?
> >
> > Try
> >
> > x and y
> >
> > and
> >
> > x or y
> >
> > When those jump, they want to retain the tested value, so
> > there's no POP_TOP
> > at the branch target then.
>
> Ah. They only POP_TOP if they *don't* jump. Got it. Thanks!
I think you may want to play around with chained comparisons, too,
IIRC. We Have Been Here Before :-)
Cheers,
mwh
--
The above comment may be extremely inflamatory. For your
protection, it has been rot13'd twice.
-- the signature of "JWhitlock" on slashdot
More information about the Python-list
mailing list