Message280999
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:31 | wolma | set | recipients:
+ wolma, mark.dickinson, serhiy.storchaka, josh.r |
2016-11-16 22:20:31 | wolma | set | messageid: <1479334831.31.0.809354324034.issue28716@psf.upfronthosting.co.za> |
2016-11-16 22:20:31 | wolma | link | issue28716 messages |
2016-11-16 22:20:31 | wolma | create | |
|