0

I'm having trouble finding information about how nesting dicts affects performance. My assumption is nesting makes searches faster, but I just want to confirm that I'm understanding this correctly.

note: let's assume these dicts are much bigger (if the specific size is important, let me know)

Here are two examples:

people = 
{
    'person1':
        {
            'name':
                {
                    'first': 'John',
                    'middle': 'Charles',
                    'last': 'Doe'
                },
            'age': '27',
            'sex': 'Male',
        },
}

compared to:

people = 
{
    'person1':
        {
            'name': 'John Charles Doe',
            'firstname': 'John',
            'middlename': 'Charles',
            'lastname': 'Doe',
            'age': '27',
            'sex': 'Male',
        },
}
cor manet
  • 13
  • 4
  • I imagine that there are different answers for different programming languages and their various implementations. Please [edit] the question to explain further. – AdrianHHH Apr 04 '19 at 18:08
  • @AdrianHHH I added the python tag. Sorry about that. – cor manet Apr 04 '19 at 18:15
  • The answer here might be helpful for you: https://stackoverflow.com/questions/7147785/nested-dictionaries-or-tuples-for-key – TYZ Apr 04 '19 at 18:17
  • @YilunZhang Thank you. – cor manet Apr 04 '19 at 18:27
  • Possible duplicate of [nested dictionaries or tuples for key?](https://stackoverflow.com/questions/7147785/nested-dictionaries-or-tuples-for-key) – perennial_noob Apr 04 '19 at 18:40
  • @perennial_noob Yes, possibly. I'm struggling to understand what that thread op is asking and whether it is the same as my question. My dict only goes 3 keys deep so maybe it's a non-issue. – cor manet Apr 04 '19 at 19:45

0 Answers0