[issue46780] Allow Fractions to return 1/6 for "0.17", "0.167", "0.1667", etc.

Raymond Hettinger report at bugs.python.org
Thu Feb 17 18:29:30 EST 2022


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

>  Nor will it achieve world peace.

Please watch the tone. It is borderline abusive and dismissive.

> we can invoke the attached as best_fraction(Fraction("0.001"),
> Fraction("0.0005"), Fraction("0.0015")) to get the output
> Fraction(1, 1000).

-1 I am solidly against this.  The other inputs to Fraction() are exact conversions.  The proposal works against a core concept behind the fraction module. 

Also, my expectation for Fraction("0.0015") would be to give Fraction(3, 2000), the same as would be given by Fraction(Decimal("0.0015")).

> But if it solves enough use cases then it is worth discussing, yes?

Perhaps this tracker issue should be closed and moved to python-ideas.  The notions are currently too immature to warrant more core developer time.

Also, it would be nice to have research into what other languages and libraries do for fractional approximations of decimal strings.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46780>
_______________________________________


More information about the Python-bugs-list mailing list