gh-82017: Support as_integer_ratio() in the Fraction constructor
Any numbers that have the as_integer_ratio() method (e.g. numpy.float128) can now be converted to a fraction.
- Issue: gh-82017
📚 Documentation preview 📚: https://cpython-previews--120271.org.readthedocs.build/
I'd welcome thoughts from @rhettinger on this particular change.
Then isinstance(numerator, numbers.Number) should be replaced by not isinstance(numerator, type). We need at least exclude types, because the type has the same method as an instance.
I'd welcome thoughts from @rhettinger on this particular change.
This seems reasonable to me.
I would leave off the isinstance() check and use pure duck-typing for the as_integer_ratio() method.