Message52968
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.
|
|
Date |
User |
Action |
Args |
2007-08-23 15:59:29 | admin | link | issue1764087 messages |
2007-08-23 15:59:29 | admin | create | |
|