[issue37836] Support .as_integer_ratio() in fractions.Fraction

2022-01-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't think this is a door we should open: >>> Fraction(3.5, 2.5) Fraction(7, 5) This currently raises a useful exception: TypeError: both arguments should be Rational instances That is especially helpful in avoiding cases like this: >>>

[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-19 Thread Jeroen Demeyer
Jeroen Demeyer added the comment: > I afraid this can slow down the Fraction constructor. No, it doesn't! It even speeds up the constructor in some cases: ./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 1' 'Fraction(x)' BEFORE: Mean +- std dev: 826 ns +- 20

[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-19 Thread Jeroen Demeyer
Jeroen Demeyer added the comment: > See issue37884 which uses a C accelerator. Note that that doesn't replace this issue, because I need to support as_integer_ratio both in the *numerator* and *denominator*. -- ___ Python tracker

[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See issue37884 which uses a C accelerator. -- ___ Python tracker ___ ___ Python-bugs-list

[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I afraid this can slow down the Fraction constructor. -- ___ Python tracker ___ ___

[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-18 Thread Jeroen Demeyer
Change by Jeroen Demeyer : -- pull_requests: +15046 pull_request: https://github.com/python/cpython/pull/15328 ___ Python tracker ___

[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-18 Thread Jeroen Demeyer
Change by Jeroen Demeyer : -- keywords: +patch pull_requests: +15045 stage: -> patch review pull_request: https://github.com/python/cpython/pull/15327 ___ Python tracker ___

[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-13 Thread Jeroen Demeyer
New submission from Jeroen Demeyer : Currently, the fractions.Fraction constructor accepts an .as_integer_ratio() method only for the specific types "float" and "Decimal". It would be good to support this for arbitrary classes. This is part of what was proposed in #37822, but without adding