SIGN IN SIGN UP

gh-111139: Optimize math.gcd(int, int) (#113887)

Add a fast-path for the common case.

Benchmark:

    python -m pyperf timeit \
        -s 'import math; gcd=math.gcd; x=2*3; y=3*5' \
        'gcd(x,y)'

Result: 1.07x faster (-3.4 ns)

    Mean +- std dev: 52.6 ns +- 4.0 ns -> 49.2 ns +- 0.4 ns: 1.07x faster
V
Victor Stinner committed
93930eaf0acd64dc0d08d58321d2682cb019bc1a
Parent: 66363b9
Committed by GitHub <noreply@github.com> on 1/10/2024, 3:38:56 PM