[Python-Dev] Symmetry arguments for API expansion

Guido van Rossum guido at python.org
Tue Mar 13 11:23:38 EDT 2018


On Mon, Mar 12, 2018 at 10:01 PM, Tim Peters <tim.peters at gmail.com> wrote:

> At heart, the Fraction() constructor is _all about_ creating integer
> ratios, so is the most natural place to put knowledge of how to do so.
> A protocol for allowing new numeric types to get converted to Fraction
> would be more generally useful than just a weird method only datetime
> uses ;-)
>

Ironically, the various Fraction constructors *calls* as_integer_ratio()
for floats and Decimals. From which follows IMO that the float and Decimal
classes are the right place to encapsulate the knowledge on how to do it.

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


More information about the Python-Dev mailing list