This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eltoder
Recipients eltoder
Date 2011-03-11.21:49:15
SpamBayes Score 2.813574e-07
Marked as misclassified No
Message-id <1299880156.4.0.0999870554397.issue11471@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-03-11 21:49:16eltodersetrecipients: + eltoder
2011-03-11 21:49:16eltodersetmessageid: <1299880156.4.0.0999870554397.issue11471@psf.upfronthosting.co.za>
2011-03-11 21:49:15eltoderlinkissue11471 messages
2011-03-11 21:49:15eltodercreate