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 Scott Norton
Recipients Scott Norton
Date 2020-12-21.15:25:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1608564339.76.0.67705848453.issue42706@roundup.psfhosted.org>
In-reply-to
Content
The library function random.uniform takes about twice as long as a manual inline implementation (Python 3.9.1).

>>> import timeit
>>> timeit.timeit('3 + (8 - 3) * random.random()', 'import random')
0.1540887290000228
>>> timeit.timeit('a + (b - a) * random.random()', 'import random\na = 3\nb = 8')
0.17950458899986188
>>> timeit.timeit('random.uniform(3, 8)', 'import random')  # does the call/return really add that much overhead?
0.31145418699999894
History
Date User Action Args
2020-12-21 15:25:39Scott Nortonsetrecipients: + Scott Norton
2020-12-21 15:25:39Scott Nortonsetmessageid: <1608564339.76.0.67705848453.issue42706@roundup.psfhosted.org>
2020-12-21 15:25:39Scott Nortonlinkissue42706 messages
2020-12-21 15:25:39Scott Nortoncreate