I use the python dictionary to store a large number of objects and there is a line name for each of them. To be specific here, my code is:
from itertools import product
for (i,j,k) in product(range(N),range(M),range(K)):
var_name='x_'+'_'+str(i)+str(j)+'_'+str(k)
var_dict[var_name] = f(var_name,other_params)
print len(var_dict)
f (...) returns an object. In my code, N = 363, M = 500, and K = 2. Therefore, I expect 363,000 entries in the dictionary. But when I check the length of var_dict, it is 330860 !!!
(Pdb) len (var_dict) 330860
Here are my questions: 1) Are there any explanations for this? For instance. Is there any limit to the number of elements that the python built-in hash table can address?
2) What can I do to solve this problem?
Thank!
source
share