This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author wolma
Recipients josh.r, mark.dickinson, serhiy.storchaka, wolma
Date 2016-11-16.22:20:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.
Date User Action Args
2016-11-16 22:20:31wolmasetrecipients: + wolma, mark.dickinson, serhiy.storchaka, josh.r
2016-11-16 22:20:31wolmasetmessageid: <>
2016-11-16 22:20:31wolmalinkissue28716 messages
2016-11-16 22:20:31wolmacreate