Message89408
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?) |
|
Date |
User |
Action |
Args |
2009-06-15 19:08:29 | abbeyj | set | recipients:
+ abbeyj, collinwinter, rhettinger, pitrou, jyasskin |
2009-06-15 19:08:28 | abbeyj | set | messageid: <1245092908.94.0.917434465219.issue6250@psf.upfronthosting.co.za> |
2009-06-15 19:08:27 | abbeyj | link | issue6250 messages |
2009-06-15 19:08:27 | abbeyj | create | |
|