[Python-Dev] Expose stack effects to Python?

Larry Hastings larry at hastings.org
Wed Jul 3 10:36:24 CEST 2013



I wrote my own assembler for Python bytecode called "Maynard".  I had to 
statically compute the stack effects for each bytecode instruction by 
hand; what I did was copied and pasted opcode_stack_effect() (which is 
static) out of Python/compile.c and into my own driver program, then I 
probed it with test values to produce a table.  I then coded up a 
function using that table, but hand-calculating the value sometimes as 
there are some opcodes whose stack effect varies based on the oparg.

It sure would be nice if this information was simply available to the 
Python interpreter; theoretically it can change between point releases.  
Would anybody mind if I added it somewhere?  I'd probably just expose 
opcode_stack_effect to Python, then add all this other junk to the dis 
module and make it available there.


//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130703/e6edf6c6/attachment.html>


More information about the Python-Dev mailing list