]> granicus.if.org Git - python/commit
Hoist the float conversion out of the inner loop. (GH-10430)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Fri, 9 Nov 2018 10:39:50 +0000 (02:39 -0800)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 9 Nov 2018 10:39:50 +0000 (02:39 -0800)
commit0a18e0510a145427d8ff1864a011c81ea02cdcd4
tree1f9e4f52be6672e8fc802e0276c4638db1eaf28c
parentcf5863faabe011a61827b9b9982dba3d6a381f0f
Hoist the float conversion out of the inner loop. (GH-10430)

Currently, the *n* and *total* variables get converted to floats each time they are multiplied by random().  This minor tweak does the conversion just once and gets a small speedup (approx 3%).
Lib/random.py