]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Minor optimization for Fractions.limit_denominator (GH-93730)
authorMark Dickinson <dickinsm@gmail.com>
Tue, 21 Jun 2022 19:36:35 +0000 (20:36 +0100)
committerGitHub <noreply@github.com>
Tue, 21 Jun 2022 19:36:35 +0000 (21:36 +0200)
commit420f0df862cf2290ad6a5e25286925ad197c9ef5
tree12237387683de3e6f06fa00da91d92b5de66fd6e
parent830513754d081619b2d72db17770627312072fa5
Minor optimization for Fractions.limit_denominator (GH-93730)

When we construct the upper and lower candidates in limit_denominator,
the numerator and denominator are already relatively prime (and the
denominator positive) by construction, so there's no need to go through
the usual normalisation in the constructor. This saves a couple of
potentially expensive gcd calls.

Suggested by Michael Scott Asato Cuthbert in GH-93477.
Lib/fractions.py