Message130623
If statement without else part generates unnecessary JUMP_FORWARD insn with jumps right to the next insn:
>>> def foo(x):
if x: x = 1
>>> dis(foo)
2 0 LOAD_FAST 0 (x)
3 POP_JUMP_IF_FALSE 15
6 LOAD_CONST 1 (1)
9 STORE_FAST 0 (x)
12 JUMP_FORWARD 0 (to 15)
>> 15 LOAD_CONST 0 (None)
18 RETURN_VALUE
This patch suppresses generation of this jump.
Testing revealed another issue: when AST is produced from string empty 'orelse' sequences are represented with NULLs. However when AST is converted from Python AST objects empty 'orelse' is a pointer to 0-length sequence. I've changed this to produce NULL pointers, like in the string case. This uses less memory and doesn't introduce different code path in compiler. Without this change test_compile failed with my first change.
make test passes. |
|
Date |
User |
Action |
Args |
2011-03-11 21:49:16 | eltoder | set | recipients:
+ eltoder |
2011-03-11 21:49:16 | eltoder | set | messageid: <1299880156.4.0.0999870554397.issue11471@psf.upfronthosting.co.za> |
2011-03-11 21:49:15 | eltoder | link | issue11471 messages |
2011-03-11 21:49:15 | eltoder | create | |
|