Last active
October 7, 2020 12:40
-
-
Save madewulf/6844cef0d23f0a895051472e71355102 to your computer and use it in GitHub Desktop.
Set performance test (less than 10 seconds on my Mac)
This file contains 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
from uuid import uuid4 | |
s = set() | |
for i in range (500000): | |
s.add(str(uuid4())) | |
count = 0 | |
for uu in s: | |
if uu in s: | |
count += 1 | |
print(count) | |
if "other_string" not in s: | |
print("this is normal") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This generates a set of 500 000 random strings and then test if each one is in the set. It takes less than 10 seconds on my Mac