Skip to content

Instantly share code, notes, and snippets.

@tkw1536
Created August 7, 2019 13:10
Show Gist options
  • Save tkw1536/89296ad43702cc131eccd00cddadc8d7 to your computer and use it in GitHub Desktop.
Save tkw1536/89296ad43702cc131eccd00cddadc8d7 to your computer and use it in GitHub Desktop.
A check if Python's UUIDs are reasonably unique
import uuid
ids = set()
i = 0
MAX = 10 ** 7
while i < MAX:
u = str(uuid.uuid4())
if u in ids:
print("{}: {} DUPLICATE".format(i, u))
break
ids.add(u)
print("{}: {} OK".format(i, u))
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment