James Abbatiello <abb...@gmail.com> added the comment: I should add that the patch doesn't only address dead user-code. It also eliminates code that the compiler generates itself but that would be unreachable at runtime. Consider the following function:
def foo(x): if x: raise Something else: raise SomethingElse Without the patch this would compile to: 2 0 LOAD_FAST 0 (x) 3 POP_JUMP_IF_FALSE 15 3 6 LOAD_GLOBAL 0 (Something) 9 RAISE_VARARGS 1 12 JUMP_FORWARD 6 (to 21) 5 >> 15 LOAD_GLOBAL 1 (SomethingElse) 18 RAISE_VARARGS 1 >> 21 LOAD_CONST 0 (None) 24 RETURN_VALUE With the patch this slims down to: 2 0 LOAD_FAST 0 (x) 3 POP_JUMP_IF_FALSE 12 3 6 LOAD_GLOBAL 0 (Something) 9 RAISE_VARARGS 1 5 >> 12 LOAD_GLOBAL 1 (SomethingElse) 15 RAISE_VARARGS 1 So there are benefits even for normal code. Also the END_FINALLY handling would be really hard to do in a pure bytecode walker since context from the AST is needed (am I in a try-finally or try-except or with statement?) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6250> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com