[issue37822] Add math.as_integer_ratio()

2019-08-12 Thread Jeroen Demeyer
Jeroen Demeyer added the comment: Aren't you worried about using the non-special non-reserved attributes like "as_integer_ratio"? That's the reason why I proposed a dunder name "__ratio__" instead of "as_integer_ratio". In my opinion, it was a mistake in PEP 3141 to use non-reserved names

[issue37822] Add math.as_integer_ratio()

2019-08-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: Guido decided to stick with the current approach of adding as_integer_ratio() as needed to concrete classes. It is an optional API for user classes that register as numbers.Rational(). See https://bugs.python.org/msg349404 -- resolution: ->

[issue37822] Add math.as_integer_ratio()

2019-08-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: -1 for having this spill into the math module. We're already started down a different path; otherwise, there would have been no need to add the as_integer_ratio method to int/bool. That was done so that x.as_integer_ratio() would work for all the

[issue37822] Add math.as_integer_ratio()

2019-08-11 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +14938 stage: -> patch review pull_request: https://github.com/python/cpython/pull/15210 ___ Python tracker

[issue37822] Add math.as_integer_ratio()

2019-08-11 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : 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