size of nested dictionary and list
<p>I have dictionary with following format:</p>

<p>Demo code:</p>

<pre><code>&gt;&gt;&gt; import pprint
&gt;&gt;&gt; pprint.pprint(data)
{'lookup': {'F01': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F02': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F03': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F04': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F05': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F06': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F07': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F08': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F09': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F10': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F11': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }',
            'F12': '\n.custom1 {\n    background-color: #f5e9dc;\n    padding: 10px;\n    border-radius: 10px;\n    font-family: sans-serif;\n    font-size: 0.9em;\n    margin-top: 1em;\n    }\n.custom2 .style8-rw {\n    font-family: sans-serif;\n    font-weight: bold;\n    color: #F57215;\n    }'},
 'sequence': ['F01',
              'F02',
              'F03',
              'F04',
              'F05',
              'F06',
              'F07',
              'F08',
              'F09',
              'F10',
              'F11',
              'F12']}
&gt;&gt;&gt; import sys
&gt;&gt;&gt; sys.getsizeof(data)
136
&gt;&gt;&gt; sys.getsizeof(data["sequence"])
80
&gt;&gt;&gt; sys.getsizeof(data["lookup"])
520
&gt;&gt;&gt; 
</code></pre>

<p>I can not get how nested dictionary is store in memory because size if <code>data</code> is 136 bytes and size of <code>data["sequence"]</code> is 80 bytes and also size of <code>data["lookup"]</code> is 520 bytes.</p>

<p>Also when I do type casting of variable data from <code>dictionary</code> to <code>string</code> then size of string variable is <code>3587 bytes</code>.</p>

<p>Demo Code:</p>

<pre><code>&gt;&gt;&gt; data_str = str(data)
&gt;&gt;&gt; sys.getsizeof(data_str)
3587
</code></pre>

<p>Can any on explain me why?</p>