Author serhiy.storchaka
Recipients Nofar Schnider, gvanrossum, mark.dickinson, rhettinger, serhiy.storchaka, tim.peters
Date 2018-03-15.11:51:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521114688.98.0.467229070634.issue33073@psf.upfronthosting.co.za>
In-reply-to
Content
Adding as_integer_ratio() to numbers.Rational is a breaking change. It breaks the interface. Currently all numbers.Rational subclasses implement all public methods and properties of the abstract class, but with adding as_integer_ratio() this will be no longer true.

>>> issubclass(numpy.int64, numbers.Rational)
True
>>> numpy.int64.as_integer_ratio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'numpy.int64' has no attribute 'as_integer_ratio'

I suggest to make as_integer_ratio() creating an implicit interface (as write() creates an implicit interface for writable file-like objects), and add a convenient function (in the numbers or the math module) which calls this method if it exists and falls back to the (nominator, denominator) pair otherwise.
History
Date User Action Args
2018-03-15 11:51:29serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, tim.peters, rhettinger, mark.dickinson, Nofar Schnider
2018-03-15 11:51:28serhiy.storchakasetmessageid: <1521114688.98.0.467229070634.issue33073@psf.upfronthosting.co.za>
2018-03-15 11:51:28serhiy.storchakalinkissue33073 messages
2018-03-15 11:51:28serhiy.storchakacreate