[Python-Dev] Two questions about jump opcodes

Antoine Pitrou solipsis at pitrou.net
Sat Mar 22 23:43:31 CET 2008


Hi,

I'm attempting some bytecode tweaks (see http://bugs.python.org/issue2459) and
I've got two questions about jump instructions:

- Why are there both relative and absolute jump instructions? The traditional
rationale for relative jumps (apart from position-independent code) is to allow
for shorter operand sizes; but Python opcodes all have the same operand size
(and 16 bits is more than enough to address most bytecode arrays).
- Why are relative jumps unsigned? This means they can only jump forward, and as
soon as you want to jump backward you have to switch to an absolute jump...

(in that regard, I don't understand what JUMP_FORWARD can possibly bring over
JUMP_ABSOLUTE)

Thanks for your kind answers

Antoine.




More information about the Python-Dev mailing list