Mark Dickinson <dicki...@gmail.com> added the comment:

> In what scenario would the numerator and denominator be numbers.Rational but 
> not an integer or a fraction

But that's not the issue here. The issue here is having an instance of 
`numbers.Rational` whose numerator and denominator are not specifically of 
concrete type `int`: the test that (IIUC) you're proposing to remove is:

     if type(numerator) is int is type(denominator):
         [...]

Certainly I'd expect the numerator and denominator to be instances of 
`numbers.Integral`, but that's more general than being of exact type `int`.

The `numbers.Integral` and `numbers.Rational` ABCs are deliberately not tied to 
particular concrete classes. It would be perfectly possible (and reasonable) 
for someone to have a `MyFraction` class that behaves like a `Fraction`, and 
whose numerator and denominator are instances of some other concrete class 
`MyInteger` that behaves like an integer.

The branch in the code is necessary to support that situation, so we can't 
simply remove it.

----------

_______________________________________
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

Reply via email to