Patches item #1764087, was opened at 2007-07-31 02:06
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1764087&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Paul Pogonyshev (doublep)
Assigned to: Nobody/Anonymous (nobody)
Summary: tiny addition to peephole optimizer
Initial Comment:
Tiny optimization that replaces Replace STORE_FAST x LOAD_FAST x with DUP_TOP
STORE_FAST x (for the same slot x). Targeted at quite common case:
foo = self.foo
if foo > 0:
...
No regression, seems to do what it is supposed to do on several test cases.
However, there is drawback:
def f(x):
y = x.y
if y is not None:
print y
is disassembled as follows:
2 0 LOAD_FAST 0 (x)
3 LOAD_ATTR 0 (y)
6 DUP_TOP
3 7 STORE_FAST 1 (y)
10 LOAD_CONST 0 (None)
13 COMPARE_OP 9 (is not)
16 JUMP_IF_FALSE 9 (to 28)
19 POP_TOP
4 20 LOAD_FAST 1 (y)
23 PRINT_ITEM
24 PRINT_NEWLINE
25 JUMP_FORWARD 1 (to 29)
>> 28 POP_TOP
>> 29 LOAD_CONST 0 (None)
32 RETURN_VALUE
Note that STORE_FAST "migrated" to another line. I'm not sure how important
that is.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1764087&group_id=5470
_______________________________________________
Patches mailing list
[email protected]
http://mail.python.org/mailman/listinfo/patches