Suppose there is a structure like this:
{'key1' : { 'key2' : { .... { 'keyn' : 'value' } ... } } }
Using python, I'm trying to determine advantages/disadvantages of two different approaches:
{'key1' : { 'key2' : { .... { 'keyn' : 'value' } ... } } } # A. nested dictionary
{('key1', 'key2', ...., 'keyn') : 'value'} # B. a dictionary with a tuple used like key
Then I'm interested to know, what is the best (A or B) in terms of:
- Memory occupation
- Complexity in insertion (considering collision-avoiding alorithms, etc...)
- Complexity in find
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…