Wolfgang Maier added the comment:

No, I don't think the numeric tower ABC should be replaced by duck-typing. One 
of the very reasons the fractions module exists is that it showcases how to use 
the numeric tower. If you want a class to be picked up as a Rational it should 
be registered as such. Pretty much the same goes for integer-like things. The 
direct type check for ints only exists to speed up the most obvious case, but 
anything integer-like should be registered as a numbers.Integral and it will 
just work with fractions. Beautiful stuff!

This is not the case for as_integer_ratio because that method is not defined in 
the numeric tower and this is why I think duck-typing could be of interest here 
(I'm not sure though whether its worth the somewhat decreased performance). My 
reasoning is that the standard constructor is anyway slower for floats and ints 
than the specialized classmethods for the two so people who really care about 
speed here (probably not too many) can just use the classmethods.

----------

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

Reply via email to