Skip to content

Instantly share code, notes, and snippets.

@gmarkall
Created January 4, 2019 11:06
Show Gist options
  • Select an option

  • Save gmarkall/ea1995c4257a9e9d188544dddb6045b2 to your computer and use it in GitHub Desktop.

Select an option

Save gmarkall/ea1995c4257a9e9d188544dddb6045b2 to your computer and use it in GitHub Desktop.
import hashlib
d = {}
for i in range(1200000):
k = hashlib.md5('%x' % i).digest()
d[k] = i
#for k in d.keys():
# print k
print hashlib.md5('%x' % 999999).digest() in d.keys()
print hashlib.md5('%x' % 999999).digest() in d
print hashlib.md5('%x' % 1200001).digest() in d.keys()
print hashlib.md5('%x' % 1200001).digest() in d
0 graham@gm-x220 11:05:54 ~/tmp/pypy
$ time pypy dtest.py
True
True
False
False
real 0m3.099s
user 0m2.913s
sys 0m0.158s
0 graham@gm-x220 11:06:03 ~/tmp/pypy
$ time python dtest.py
True
True
False
False
real 0m2.584s
user 0m2.463s
sys 0m0.104s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment