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 doublep
Recipients
Date 2007-07-30.23:06:40
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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.
History
Date User Action Args
2007-08-23 15:59:29adminlinkissue1764087 messages
2007-08-23 15:59:29admincreate