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 bup
Recipients bup
Date 2020-01-10.01:26:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578619594.45.0.842825761348.issue39281@roundup.psfhosted.org>
In-reply-to
Content
The title was carefully worded as I have no idea how or why what is happening is happening, only that it has been like this since a least 3.6.0. That version in particular, by the way, is able to execute a call to a python function with 1 argument 25% faster than 3.8.0 but that may be due at least in part by whatever it is that makes it much faster to a call a unary function wrapped by functools.partial by utilizing the subcript operator on an instance of a partial subtype whose __getitem__ has been set to the data descriptor partial.func... Eg:

    class Party(partial): __getitem__ = partial.func
    fast = Party(hash)
    slow = partial(hash)

    # the expression `fast[""]` runs approximately 28% faster than
    # the expression `slow("")`, and partial.func as __getitem__ is
    # confusingly 139% faster than partial.__call__...

That rather large digression aside, here's a demonstration of two functions identical in every way except the CO_NESTED bit and perhaps the names:

if 1:
    def Slow():
        global Slow
        class  Slow:
            global slow
            def slow(self): return self
        return Slow
    if  Slow():
        class Fast:
            global fast
            def fast(self): return self
    import dis
    dis.show_code(slow)
    print()
    dis.show_code(fast)
History
Date User Action Args
2020-01-10 01:26:34bupsetrecipients: + bup
2020-01-10 01:26:34bupsetmessageid: <1578619594.45.0.842825761348.issue39281@roundup.psfhosted.org>
2020-01-10 01:26:34buplinkissue39281 messages
2020-01-10 01:26:33bupcreate