title: How are variables names stored and mapped internally?
body: <p>I read <a href="https://stackoverflow.com/a/19721096/1661745">https://stackoverflow.com/a/19721096/1661745</a> and it seems that in CPython, variables are simply names that are associated with references.  </p>
  
  <blockquote>
    <p>There are several things going on with the statement x=5:</p>
    
    <ol>
    <li>an int object with the value of 5 is created (or found if it already
    exists)</li>
    <li>the name x is created (or disassociated with the last object
    'x' labeled)</li>
    <li>the reference count to the new (or found) int object is
    increased by 1</li>
    <li>the name x is associated with the object with the
    value '5' created (or found).</li>
    </ol>
  </blockquote>
  
  <p>However, I'm still not clear with exactly how variables are implemented internally.</p>
  
  <p>Namely:</p>
  
  <blockquote>
    <ol start="2">
    <li>the name x is created (or disassociated with the last object 'x' labeled);</li>
    </ol>
  </blockquote>
  
  <p>Then wouldn't the name also take up memory space? <code>sys.sizeof(x)</code> equals <code>sys.sizeof(5)</code>, and I get that <code>sys.sizeof(x)</code> could only return the size of the associated reference, but then what is the size of the name <code>x</code>?</p>
  
  <blockquote>
    <ol start="4">
    <li>the name x is associated with the object with the value '5' created (or found)</li>
    </ol>
  </blockquote>
  
  <p>How is this implemented internally? I think at a high level it can be done with a <code>dict</code>, where the key is the variable name (<code>str</code>?) and the value is the reference that it's associated with.</p>