]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-101773: Optimize creation of Fractions in private methods (#101780)
authorSergey B Kirpichev <skirpichev@gmail.com>
Mon, 27 Feb 2023 18:53:22 +0000 (21:53 +0300)
committerGitHub <noreply@github.com>
Mon, 27 Feb 2023 18:53:22 +0000 (18:53 +0000)
commit4f3786b7616dd464242b88ad6914053d409fe9d2
tree6bd17c96e33920a7e2e0e91b53adf65886e2bae7
parentbb0cf8fd60e71581a90179af63e60e8704c3814b
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>
Lib/fractions.py
Lib/test/test_fractions.py
Lib/test/test_numeric_tower.py
Misc/NEWS.d/next/Library/2023-02-10-11-59-13.gh-issue-101773.J_kI7y.rst [new file with mode: 0644]