Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33073>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to