title: About the changing id of an immutable string
body: <p>Something about the <code>id</code> of objects of type <code>str</code> (in python 2.7) puzzles me. The <code>str</code> type is immutable, so I would expect that once it is created, it will always have the same <code>id</code>. I believe I don't phrase myself so well, so instead I'll post an example of input and output sequence.</p>
  
  <pre><code>&gt;&gt;&gt; id('so')
  140614155123888
  &gt;&gt;&gt; id('so')
  140614155123848
  &gt;&gt;&gt; id('so')
  140614155123808
  </code></pre>
  
  <p>so in the meanwhile, it changes all the time. However, after having a variable pointing at that string, things change:</p>
  
  <pre><code>&gt;&gt;&gt; so = 'so'
  &gt;&gt;&gt; id('so')
  140614155123728
  &gt;&gt;&gt; so = 'so'
  &gt;&gt;&gt; id(so)
  140614155123728
  &gt;&gt;&gt; not_so = 'so'
  &gt;&gt;&gt; id(not_so)
  140614155123728
  </code></pre>
  
  <p>So it looks like it freezes the id, once a variable holds that value. Indeed, after <code>del so</code> and <code>del not_so</code>, the output of <code>id('so')</code> start changing again.</p>
  
  <p>This is <strong>not</strong> the same behaviour as with (small) integers.</p>
  
  <p>I know there is not real connection between immutability and having the same <code>id</code>; still, I am trying to figure out the source of this behaviour. I believe that someone whose familiar with python's internals would be less surprised than me, so I am trying to reach the same point...</p>
  
  <h1>Update</h1>
  
  <p>Trying the same with a different string gave different results...</p>
  
  <pre><code>&gt;&gt;&gt; id('hello')
  139978087896384
  &gt;&gt;&gt; id('hello')
  139978087896384
  &gt;&gt;&gt; id('hello')
  139978087896384
  </code></pre>
  
  <p>Now it <strong>is</strong> equal...</p>