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 vstinner
Recipients belopolsky, gladman, mark.dickinson, pitrou, scoder, serhiy.storchaka, vstinner, wolma
Date 2014-10-05.08:58:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Why patching fraction.Fraction constructor instead of fractions.gcd()?

I don't like the idea of having two functions, math.gcd and fractions.gcd, which do almost the same, but one is slow, whereas the other is fast. It's harder to write efficient code working on Python < 3.5 (use fractions) and Python >= 3.5 (use math or fractions?).

I suggest to modify fractions.gcd() to use math.gcd() if the two parameters are int. We just have to adjust the sign: if the second parameter is negative, return -math.gcd(a, b). (I guess that we have unit tests for fractions.gcd checking the 4 cases for signed parameters.)
Date User Action Args
2014-10-05 08:58:44vstinnersetrecipients: + vstinner, mark.dickinson, belopolsky, pitrou, scoder, serhiy.storchaka, wolma, gladman
2014-10-05 08:58:44vstinnersetmessageid: <>
2014-10-05 08:58:44vstinnerlinkissue22486 messages
2014-10-05 08:58:44vstinnercreate