Mark Dickinson <dicki...@gmail.com> added the comment: Here's a concrete example, using gmpy2 [1], that exercises the code path you're proposing to remove. I had to cheat a bit, since the gmpy2 types *don't* (currently) buy in to the numbers ABC tower (though there's no good reason that they couldn't do so), so I registered them manually.
>>> import fractions, numbers >>> import gmpy2 >>> x = gmpy2.mpq(2, 3) >>> numbers.Rational.register(type(x)) <class 'mpq'> >>> numbers.Integral.register(type(x.denominator)) <class 'mpz'> >>> fractions.Fraction(x, x) # code path exercised here ... Fraction(1, 1) Note that the numerator and the denominator of the resulting `Fraction` object are still of type `mpz`. It _would_ be possible to remove the check and always use `math.gcd`, but it would result in a behaviour change: for the above code, we'd get a `Fraction` whose numerator and denominator were both of actual type `int` instead of `mpz`. Whether that's a desirable behaviour change or not is another question ... [1] https://gmpy2.readthedocs.io/en/latest/ ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32466> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com