Ticket #36190: test2.py

File test2.py, 661 bytes (added by Michel Le Bihan, 4 days ago)
Line 
1import time
2
3from array import array
4from bisect import bisect_left
5from pympler import asizeof
6
7
8start = time.process_time()
9
10with open("/dev/shm/piotrcki-wordlist-top10m.txt") as f:
11 passwords = array('q', sorted({hash(x.strip()) for x in f}))
12
13print("Reading password list took:", time.process_time() - start)
14
15
16start = time.process_time()
17
18pos = bisect_left(passwords, hash("asdfjkl:"))
19is_present = pos != len(passwords) and passwords[pos] == hash("asdfjkl:")
20
21print("Checking if password is in list took:", time.process_time() - start)
22
23print("Password is in list:", is_present)
24
25print("Size of passwords in MB:", asizeof.asizeof(passwords) / 1024**2)
Back to Top