Last active
August 14, 2019 02:57
-
-
Save YontiLevin/edceec49beb9e9c3ab492537bad73251 to your computer and use it in GitHub Desktop.
n to the power of 3 dict inflation for 18 million records
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
from random import randint | |
from collections import defaultdict | |
from itertools import combinations | |
from tqdm import tqdm | |
P = defaultdict(int) | |
n = int(1e6) | |
for j in range(18): | |
print(j, len(P)) | |
for i in tqdm(range(n)): | |
l1 = [randint(0, 228) for _ in range(10)] | |
l2 = combinations(l1, 2) | |
l3 = combinations(l1, 3) | |
for c in l1: | |
P[c]+=1 | |
for c in l2: | |
sc = tuple(sorted(list(c))) | |
P[sc] += 1 | |
for c in l3: | |
sc = tuple(sorted(list(c))) | |
P[sc] += 1 | |
print(len(P)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment