[New-bugs-announce] [issue24059] Minor speed and readability improvement to the random module

Raymond Hettinger report at bugs.python.org
Sat Apr 25 17:35:48 CEST 2015


New submission from Raymond Hettinger:

Replace all the _sqrt(x) calls with x ** 0.5, improving the visual appearance and providing a modest speed improvement.

$ python3 -m timeit -s 'from math import sqrt' 'sqrt(3.14)'
10000000 loops, best of 3: 0.032 usec per loop
$ python3 -m timeit -s 'from math import sqrt' '3.14 ** 0.5'
100000000 loops, best of 3: 0.0101 usec per loop

----------
components: Library (Lib)
files: random_sqrt.diff
keywords: patch
messages: 242017
nosy: rhettinger
priority: low
severity: normal
stage: patch review
status: open
title: Minor speed and readability improvement to the random module
type: performance
versions: Python 3.5
Added file: http://bugs.python.org/file39206/random_sqrt.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24059>
_______________________________________


More information about the New-bugs-announce mailing list