[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

Antoine Pitrou report at bugs.python.org
Mon Jul 24 04:09:05 EDT 2017


Antoine Pitrou added the comment:

So, the approach of duplicating finally blocks tends to lead to a non-trivial bytecode increase.  There is even a potential combinatorial explosion with nested "try..finally" block:

def f():
    try:
        ...
    finally:
        try:
            ...
        finally:
            # etc.

Such a chain of N nested "finally"s will emit O(2**N) opcodes.

I'm not sure it's a pratical concern but I find it is detrimental to the readibility of bytecode (which is a nice thing to have when doing low-level debugging or tweaking).  I think we can massage the PR to remove the "finally" block duplication while keeping the predictable stack effect.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17611>
_______________________________________


More information about the Python-bugs-list mailing list