[Python-Dev] Symmetry arguments for API expansion

Guido van Rossum guido at python.org
Tue Mar 13 15:07:15 EDT 2018

OK, please make it so.

On Tue, Mar 13, 2018 at 11:39 AM, Raymond Hettinger <
raymond.hettinger at gmail.com> wrote:

> > On Mar 13, 2018, at 10:43 AM, Guido van Rossum <guido at python.org> wrote:
> >
> > 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. If
> this means we should add it to int, that's fine with me.
> I would like that outcome.
> The signature x.as_integer_ratio() -> (int, int) is pleasant to work
> with.  The output is easy to explain, and the denominator isn't tied to
> powers of two or ten. Since Python ints are exact and unbounded, there
> isn't worry about range or rounding issues.
> In contrast, math.frexp(float) ->(float, int) is a bit of pain because it
> still leaves you in the domain of floats rather than letting you decompose
> to more more basic types.  It's nice to have a way to move down the chain
> from ℚ, ℝ, or ℂ to the more basic ℤ (of course, that only works because
> floats and complex are implemented in a way that precludes exact
> irrationals).
> Raymond

--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180313/e540e89d/attachment.html>

More information about the Python-Dev mailing list