[issue42160] unnecessary overhead in tempfile

Eric Wolf report at bugs.python.org
Mon Oct 26 22:32:31 EDT 2020


Eric Wolf <robo-eric at gmx.de> added the comment:

SystemRandom seems to be slower:


from random import Random, SystemRandom
from timeit import timeit

user = Random()
system = SystemRandom()
characters = "abcdefghijklmnopqrstuvwxyz0123456789_"

timeit(lambda: user.choice(characters))
>>> 0.5491522020020057

timeit(lambda: system.choice(characters))
>>> 2.9195130389998667

----------

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


More information about the Python-bugs-list mailing list