bpo-37836: support .as_integer_ratio() in Fraction by jdemeyer · Pull Request #15327 · python/cpython
Conversation
When constructing instances of fractions.Fraction, the given numerator and denominator may now be any objects with an as_integer_ratio() method.
I believe we're decided that no one needs this and that it may even be hazardous — especially when accepting Fraction(2.5, 4.5) when the entire point of the fractions module is to achieve exactness by working with integer arithmetic.
I concur with @rhettinger.
I am even think that if Fraction() is called with two arguments, both of them must be integers. But the ship is already sailed, and I am not want to argue about deprecating the current behavior (accepting Rationals).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters