Skip to content

bpo-37836: support .as_integer_ratio() in Fraction - #15327

Closed
jdemeyer wants to merge 4 commits into
python:mainfrom
jdemeyer:fraction_use_as_integer_ratio
Closed

bpo-37836: support .as_integer_ratio() in Fraction#15327
jdemeyer wants to merge 4 commits into
python:mainfrom
jdemeyer:fraction_use_as_integer_ratio

Conversation

@jdemeyer

@jdemeyerjdemeyer commented Aug 18, 2019

Copy link
Copy Markdown
Contributor

When constructing instances of fractions.Fraction, the given numerator
and denominator may now be any objects with an as_integer_ratio() method.

CC @serhiy-storchaka , @rhettinger

https://bugs.python.org/issue37836

When constructing instances of fractions.Fraction, the given numerator
and denominator may now be any objects with an as_integer_ratio() method.
@aerosaeros added the type-feature A feature request or enhancement label Aug 22, 2019
Comment threadLib/fractions.py
Comment threadMisc/NEWS.d/next/Library/2019-08-18-22-29-59.bpo-37836.BbvvFm.rst Outdated
Comment threadLib/fractions.py Outdated
Comment threadLib/fractions.py Outdated
Comment threadLib/fractions.py
Comment threadLib/fractions.py
Comment threadDoc/library/fractions.rst Outdated
Comment threadDoc/library/fractions.rst Outdated
Comment threadLib/test/test_fractions.py
Comment threadMisc/NEWS.d/next/Library/2019-08-18-22-29-59.bpo-37836.BbvvFm.rst Outdated
Co-Authored-By: Ashwin Ramaswami <aramaswamis@gmail.com>
@rhettinger

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

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

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core reviewtype-featureA feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@jdemeyer@rhettinger@serhiy-storchaka@epicfaace@aeros@the-knights-who-say-ni@bedevere-bot