diff options
author | Sergey B Kirpichev <skirpichev@gmail.com> | 2023-02-27 18:53:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-27 18:53:22 (GMT) |
commit | 4f3786b7616dd464242b88ad6914053d409fe9d2 (patch) | |
tree | 6bd17c96e33920a7e2e0e91b53adf65886e2bae7 /Lib/test/test_numeric_tower.py | |
parent | bb0cf8fd60e71581a90179af63e60e8704c3814b (diff) | |
download | cpython-4f3786b7616dd464242b88ad6914053d409fe9d2.zip cpython-4f3786b7616dd464242b88ad6914053d409fe9d2.tar.gz cpython-4f3786b7616dd464242b88ad6914053d409fe9d2.tar.bz2 |
gh-101773: Optimize creation of Fractions in private methods (#101780)
This PR adds a private `Fraction._from_coprime_ints` classmethod for internal creations of `Fraction` objects, replacing the use of `_normalize=False` in the existing constructor. This speeds up creation of `Fraction` objects arising from calculations. The `_normalize` argument to the `Fraction` constructor has been removed.
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Diffstat (limited to 'Lib/test/test_numeric_tower.py')
-rw-r--r-- | Lib/test/test_numeric_tower.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/test/test_numeric_tower.py b/Lib/test/test_numeric_tower.py index 9cd85e1..337682d 100644 --- a/Lib/test/test_numeric_tower.py +++ b/Lib/test/test_numeric_tower.py @@ -145,7 +145,7 @@ class HashTest(unittest.TestCase): # The numbers ABC doesn't enforce that the "true" division # of integers produces a float. This tests that the # Rational.__float__() method has required type conversions. - x = F(DummyIntegral(1), DummyIntegral(2), _normalize=False) + x = F._from_coprime_ints(DummyIntegral(1), DummyIntegral(2)) self.assertRaises(TypeError, lambda: x.numerator/x.denominator) self.assertEqual(float(x), 0.5) |