[Python-Dev] Symmetry arguments for API expansion

Tim Peters tim.peters at gmail.com
Tue Mar 13 14:38:53 EDT 2018


[Guido]
> So let's make as_integer_ratio() the standard protocol for "how to make a
> Fraction out of a number that doesn't implement numbers.Rational". We
> already have two examples of this (float and Decimal) and perhaps numpy or
> the sometimes proposed fixed-width decimal type can benefit from it too.

Yup, that works.  I only would have preferred that you went back in
time to add a leading underscore.


> If this means we should add it to int, that's fine with me.

Given that int.numerator and int.denominator already exist, there's no
plausible "good reason" to refuse to return them as twople.  Still,
I'd wait for someone to complain ;-)


More information about the Python-Dev mailing list