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 rhettinger
Recipients lukasz.langa, petr.viktorin, pitrou, rhettinger, skrah, vstinner
Date 2020-07-07.17:53:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1594144434.3.0.59988005976.issue39542@roundup.psfhosted.org>
In-reply-to
Content
Here are two timings for math.dist().  They were run with the production macOS builds from python.org:

$ python3.8 -m timeit -r 11 -s 'from math import dist' -s 'p=(1.1, 2.2); q=(1.7, 2.3)' 'dist(p, q)'
5000000 loops, best of 11: 58.4 nsec per loop

$ python3.9 -m timeit -r 11 -s 'from math import dist' -s 'p=(1.1, 2.2); q=(1.7, 2.3)' 'dist(p, q)'
5000000 loops, best of 11: 66.9 nsec per loop

The attached screen shot shows that the only change between the two versions is that the subclass check is inlined and fast in 3.8, but is an external function call in 3.9.

---- 3.8 subclass check -----------
    movq    8(%r12), %rax
    movl    $0, 32(%rsp)
    testb   $4, 171(%rax)
    je  L779

---- 3.9 subclass check -----------

    movq    8(%r12), %rdi
    call    _PyType_GetFlags
    movl    $0, 32(%rsp)
    testl   $67108864, %eax
    je  L856

The C code for math.dist() is unchanged between 3.8 and 3.9.  Both use PyTuple_Check().

This isn't unique.  Every single PyTuple_Check() is the similarly affected (approx. 225 occurrences).  Presumably, this affects other type checks as well.
History
Date User Action Args
2020-07-07 17:53:54rhettingersetrecipients: + rhettinger, pitrou, vstinner, petr.viktorin, skrah, lukasz.langa
2020-07-07 17:53:54rhettingersetmessageid: <1594144434.3.0.59988005976.issue39542@roundup.psfhosted.org>
2020-07-07 17:53:54rhettingerlinkissue39542 messages
2020-07-07 17:53:54rhettingercreate