R
Robert Brewer
Playing around with bytecodes some more:
.... if x:
.... y
.... else:
.... z
.... 2 0 LOAD_FAST 0 (x)
3 JUMP_IF_FALSE 8 (to 14)
6 POP_TOP
3 7 LOAD_GLOBAL 1 (y)
10 POP_TOP
11 JUMP_FORWARD 5 (to 19)
5 15 LOAD_GLOBAL 2 (z)
18 POP_TOP 22 RETURN_VALUE
I notice that, whether JUMP_IF_FALSE jumps or not, the next instruction
it executes is POP_TOP (in the above, instruction numbers 6 and 14). Are
there any constructions whereby this does not happen for JUMP_IF_FALSE
and JUMP_IF_TRUE? If there aren't, is it just explicitness that kept
JUMP_IF_* from doing the POP on its own, before the jump (which would
thereby save two instructions)?
Robert Brewer
MIS
Amor Ministries
(e-mail address removed)
.... if x:
.... y
.... else:
.... z
.... 2 0 LOAD_FAST 0 (x)
3 JUMP_IF_FALSE 8 (to 14)
6 POP_TOP
3 7 LOAD_GLOBAL 1 (y)
10 POP_TOP
11 JUMP_FORWARD 5 (to 19)
5 15 LOAD_GLOBAL 2 (z)
18 POP_TOP 22 RETURN_VALUE
I notice that, whether JUMP_IF_FALSE jumps or not, the next instruction
it executes is POP_TOP (in the above, instruction numbers 6 and 14). Are
there any constructions whereby this does not happen for JUMP_IF_FALSE
and JUMP_IF_TRUE? If there aren't, is it just explicitness that kept
JUMP_IF_* from doing the POP on its own, before the jump (which would
thereby save two instructions)?
Robert Brewer
MIS
Amor Ministries
(e-mail address removed)