This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jdemeyer
Recipients jdemeyer, mark.dickinson, rhettinger, serhiy.storchaka, stutzbach
Date 2019-08-19.09:08:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566205686.32.0.191589220181.issue37836@roundup.psfhosted.org>
In-reply-to
Content
> 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 ns
AFTER:  Mean +- std dev: 814 ns +- 17 ns

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 1' 'Fraction(x, x)'
BEFORE: Mean +- std dev: 1.44 us +- 0.03 us
AFTER:  Mean +- std dev: 1.46 us +- 0.02 us

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = Fraction(1)' 'Fraction(x)'
BEFORE: Mean +- std dev: 1.64 us +- 0.03 us
AFTER:  Mean +- std dev: 1.30 us +- 0.04 us

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = Fraction(1)' 'Fraction(x, x)'
BEFORE: Mean +- std dev: 3.03 us +- 0.05 us
AFTER:  Mean +- std dev: 2.34 us +- 0.06 us

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 1.0' 'Fraction(x)'
BEFORE: Mean +- std dev: 1.82 us +- 0.02 us
AFTER:  Mean +- std dev: 1.29 us +- 0.04 us
History
Date User Action Args
2019-08-19 09:08:06jdemeyersetrecipients: + jdemeyer, rhettinger, mark.dickinson, stutzbach, serhiy.storchaka
2019-08-19 09:08:06jdemeyersetmessageid: <1566205686.32.0.191589220181.issue37836@roundup.psfhosted.org>
2019-08-19 09:08:06jdemeyerlinkissue37836 messages
2019-08-19 09:08:06jdemeyercreate