title: Memory-usage of dictionary in Python?
body: <p>I am slightly confused when I use the <code>getsizeof</code> method in the <code>sys</code> module for dictionaries. Below I have created a simple dictionary of two strings. The two strings' sizes are clearly larger than the one of the dictionary. The dictionary size is probably the dictionary overhead only, i.e., it doesn't take the actual data into account. What is the best way to figure out the memory-usage of the whole dictionary (keys, values, dictionary overhead)? </p>
  
  <pre><code>&gt;&gt;&gt; first = 'abc'*1000
  &gt;&gt;&gt; second = 'def'*1000
  &gt;&gt;&gt; my_dictionary = {'first': first, 'second': second}
  &gt;&gt;&gt; getsizeof(first)
  3021
  &gt;&gt;&gt; getsizeof(second)
  3021
  &gt;&gt;&gt; getsizeof(my_dictionary)
  140
  </code></pre>