title: Why does Python2.7 dict use more space than Python3 dict?
body: <p>I've read about <a href="https://mail.python.org/pipermail/python-dev/2012-December/123028.html" rel="nofollow noreferrer">Raymond Hettinger's new method</a> of implementing <a href="https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-compactdict" rel="nofollow noreferrer">compact dicts</a>. This explains why dicts in Python 3.6 use less memory than dicts in Python 2.7-3.5. However there seems to be a difference between the memory used in Python 2.7 and 3.3-3.5 dicts. Test code:</p>
  
  <pre><code>import sys
  
  d = {i: i for i in range(n)}
  print(sys.getsizeof(d))
  </code></pre>
  
  <ul>
  <li>Python 2.7: 12568</li>
  <li>Python 3.5: 6240</li>
  <li>Python 3.6: 4704</li>
  </ul>
  
  <p>As mentioned I understand the savings between 3.5 and 3.6 but am curious about the cause of the savings between 2.7 and 3.5.</p>