◐ Shell
clean mode source ↗

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.

aeros

epicfaace

epicfaace

Co-Authored-By: Ashwin Ramaswami <aramaswamis@gmail.com>

@rhettinger

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.

@serhiy-storchaka

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).

Labels