[issue32466] Remove fractions._gcd()

Mark Dickinson report at bugs.python.org
Sun Dec 31 15:38:10 EST 2017


Mark Dickinson <dickinsm at gmail.com> added the comment:

> if math.gcd() only accepts integers and not, at least, numbers.Integral, wouldn't that be a bug?

I'd call it an enhancement opportunity rather than a bug. :-) There's no general Python-wide requirement that an instance of numbers.Integral should be acceptable anywhere an int is (though I agree that it's a nice property to have in general).

But as it happens, math.gcd _does_ accept instances of numbers.Integral, since any such instance should implement the __index__ method to convert itself to a plain old int, and math.gcd passes its arguments through PyNumber_Index.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32466>
_______________________________________


More information about the Python-bugs-list mailing list