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 Sergey.Kirpichev
Recipients Sergey.Kirpichev, mark.dickinson, rhettinger
Date 2021-03-07.04:23:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615090998.74.0.128389985738.issue43420@roundup.psfhosted.org>
In-reply-to
Content
I have similar timings (for a draft version of PR, see f.patch) as for the last comment, though the small-dens overhead seems to be bigger(~20%):
$ python3.10 -m timeit -r11 -s 'from fractions import Fraction as F' -s 'a=F(10,3)' -s 'b=F(6, 5)' 'a * b'
50000 loops, best of 11: 9.09 usec per loop
$ python3.10 -m timeit -r11 -s 'from patched import Fraction as F' -s 'a=F(10,3)' -s 'b=F(6, 5)' 'a * b'
20000 loops, best of 11: 11.2 usec per loop

On another hand, here are timings for bigger denominators:
$ python3.10 -m timeit -r11 -s 'from fractions import Fraction as F' -s 'import random' -s 'n = [random.randint(1, 1000000) for _ in range(1000)]' -s 'd = [random.randint(1, 1000000) for _ in range(1000)]' -s 'a=list(map(lambda x: F(*x), zip(n, d)))' 'sum(a)'
1 loop, best of 11: 257 msec per loop
$ ... from patched ...
10 loops, best of 11: 33.2 msec per loop

It's not so clear what "are very large" does mean, that could be defined here.  BTW, 10**6 denominators are (very!) small for mentioned above use case (CAS package).
History
Date User Action Args
2021-03-07 04:23:18Sergey.Kirpichevsetrecipients: + Sergey.Kirpichev, rhettinger, mark.dickinson
2021-03-07 04:23:18Sergey.Kirpichevsetmessageid: <1615090998.74.0.128389985738.issue43420@roundup.psfhosted.org>
2021-03-07 04:23:18Sergey.Kirpichevlinkissue43420 messages
2021-03-07 04:23:17Sergey.Kirpichevcreate