New submission from Serhiy Storchaka <storchaka+cpyt...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue37822>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to