[New-bugs-announce] [issue37822] Add math.as_integer_ratio()

Serhiy Storchaka report at bugs.python.org
Sun Aug 11 09:55:05 EDT 2019


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

There are two interfaces to represent a number as a ratio. The numbers.Rational interface has two properties: numerator and denominator. float and Decimal do not support this interface, but they provide method as_integer_ratio() which return a 2-tuple (numerator, denominator).

I propose to add math.as_integer_ratio() which unites both interfaces: uses the as_integer_ratio() method if it is defined, and uses the numerator and denominator properties otherwise. It will help in applications that work with exact numbers (e.g. modules fractions and statistics).

----------
components: Library (Lib)
messages: 349390
nosy: mark.dickinson, rhettinger, serhiy.storchaka, stutzbach
priority: normal
severity: normal
status: open
title: Add math.as_integer_ratio()
type: enhancement
versions: Python 3.9

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


More information about the New-bugs-announce mailing list