[issue42706] random.uniform 2x slower than inline implementation

Raymond Hettinger report at bugs.python.org
Mon Dec 21 12:35:04 EST 2020


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

> does the call/return really add that much overhead?

Yes, it does.

$ python3.9 -m timeit -s 'x=3.5' 'x**2'
5000000 loops, best of 5: 63.5 nsec per loop
$ python3.9 -m timeit -s 'x=3.5' -s 'f=lambda x: x**2' 'f(x)'
2000000 loops, best of 5: 136 nsec per loop

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list