[issue32455] PyCompile_OpcodeStackEffect() and dis.stack_effect() are not particularly useful

Larry Hastings report at bugs.python.org
Wed Jan 3 20:31:26 EST 2018


Larry Hastings <larry at hastings.org> added the comment:

> 1. This will actually simplify the code for calculating the stack size.

Simplify whose code, the caller or the callee?  It seems like it's simplifying the life of the callee (PyCompile_OpcodeStackEffectEx) at the expense of pushing complexity into the caller.


> 2. This will simplify third-party compilers (like
> https://github.com/vstinner/bytecode). They wouldn't need to
> duplicate the complicated code.

What complicated code?  Compilers simply call PyCompile_OpcodeStackEffect(), passing in an opcode + oparg pair, and it simply returns the maximum stack effect.  No crazy "is it a jump" logic needed.  Again: this may mean overallocating the stack.  But CPython has behaved like this for twenty years and I'm not convinced it's a problem that needs solving.


Victor, do you want to use Serhiy's proposed API in your library?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32455>
_______________________________________


More information about the Python-bugs-list mailing list