Created
April 8, 2016 09:37
-
-
Save her0e1c1/899e22e777be6b91c46c9ec102bb087e to your computer and use it in GitHub Desktop.
which is faster? random(string) or uuid4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[vagrant@debian-jessie]$ python -m timeit 'import string; import random; "".join([random.choice(string.digits) for _ in range(36)])' | |
100000 loops, best of 3: 15.3 usec per loop | |
python -m timeit 6.38s user 0.00s system 99% cpu 6.408 total | |
[vagrant@debian-jessie]$ python -m timeit 'import uuid; str(uuid.uuid4())' | |
100000 loops, best of 3: 18.2 usec per loop | |
python -m timeit 'import uuid; str(uuid.uuid4())' 6.13s user 1.54s system 98% cpu 7.763 total | |
[vagrant@debian-jessie]$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment