[Python-Dev] Why is Bytecode the way it is? (original) (raw)
Robert Brewer fumanchu at amor.org
Thu Jul 8 18:23:56 CEST 2004
- Previous message: [Python-Dev] Capitalisation of Decimal class
- Next message: [Python-Dev] Why is Bytecode the way it is?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Paul Prescod wrote:
>>> def foo(a): ... b = a + 5 ... return b
Why does the RETURNVALUE opcode have to return something from the stack? Why not have a RETURNVAR opcode that would directly return a variable or constant? (a leading bit could indicate whether to look in the const or var tuple).
I notice that your example could be rewritten to return directly from the stack. Perhaps the 'code' module could grow an .optimize function or submodule...?
And as long as we are talking about referring to things more directly, wouldn't it be possible to refer to constants by pointer rather than indirecting through the index? You'd have to fix up pointers when you first loaded the code but only once per function.
Then all our fancy bytecode hacks would have to redirect the pointers back into the index again. ;)
Robert Brewer MIS Amor Ministries fumanchu at amor.org
- Previous message: [Python-Dev] Capitalisation of Decimal class
- Next message: [Python-Dev] Why is Bytecode the way it is?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]