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 pablogsal
Recipients Anthony Sottile, pablogsal
Date 2020-01-05.10:18:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578219488.98.0.412207951188.issue39216@roundup.psfhosted.org>
In-reply-to
Content
If you want to add a test, you could check the dis output for this example:

def make_func(x):
     def f(x : not  (x is x), /): ...

In this case the compiler emits:

  3           0 LOAD_GLOBAL              0 (x)
              2 LOAD_GLOBAL              0 (x)
              4 COMPARE_OP               8 (is)
              6 UNARY_NOT
              8 LOAD_CONST               1 (('x',))
             10 BUILD_CONST_KEY_MAP      1
             12 LOAD_CONST               2 (<code object f at 0x7f3754f71040, file "/home/pablogsal/github/python/master/lel.py", line 3>)
             14 LOAD_CONST               3 ('code.<locals>.f')
             16 MAKE_FUNCTION            4 (annotations)
             18 STORE_FAST               0 (f)

while for 

def make_func(x):
     def f(x : not  (x is x)): .

emits more efficient code (using 'not is' instead of is and UNARY_NOT:

  4          20 LOAD_GLOBAL              0 (x)
             22 LOAD_GLOBAL              0 (x)
             24 COMPARE_OP               9 (is not)
             26 LOAD_CONST               1 (('x',))
             28 BUILD_CONST_KEY_MAP      1
             30 LOAD_CONST               4 (<code object g at 0x7f3754f135f0, file "/home/pablogsal/github/python/master/lel.py", line 4>)
             32 LOAD_CONST               5 ('code.<locals>.g')
             34 MAKE_FUNCTION            4 (annotations)
             36 STORE_FAST               1 (g)
             38 LOAD_CONST               0 (None)
             40 RETURN_VALUE

Adding the missing line makes them do the same.
History
Date User Action Args
2020-01-05 10:18:09pablogsalsetrecipients: + pablogsal, Anthony Sottile
2020-01-05 10:18:08pablogsalsetmessageid: <1578219488.98.0.412207951188.issue39216@roundup.psfhosted.org>
2020-01-05 10:18:08pablogsallinkissue39216 messages
2020-01-05 10:18:08pablogsalcreate