[issue12986] Using getrandbits() in uuid.uuid4() is faster and more readable

Serhiy Storchaka report at bugs.python.org
Sat Apr 7 19:56:04 CEST 2012


Serhiy Storchaka <storchaka at gmail.com> added the comment:

>         uuids = set()
>         for u in [uuid.uuid4() for i in range(1000)]:
>             uuids.add(u)

        uuids = {uuid.uuid4() for i in range(1000)}

However, I'm not sure of the legitimacy of replacement suitable for cryptographic use `os.urandom` on fast pseudo-random `random.getrandbits`. Especially for applications that need to generate a lot of uuids.

----------
nosy: +storchaka

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


More information about the Python-bugs-list mailing list