title: Is the `id()` of a variable associated to the value assigned to it after the variable lifetime finishes?
body: <p>I am tinkering with objects' identity in Python with the following code:</p>
  
  <pre><code>def f(var1):
      print 'Within f and BEFORE modification: var1= '+str(var1)+', id= '+str(id(var1))
      var1 = 10
      print 'Within f and AFTER modification: var1= '+str(var1)+', id= '+str(id(var1))
  
  def f2(var1):
      print 'Within f and BEFORE modification: var1= '+str(var1)+', id= '+str(id(var1))
      var1 = 1
      print 'Within f and AFTER modification: var1= '+str(var1)+', id= '+str(id(var1))
  
  def f3(var1):
      print 'Within f and BEFORE modification: var1= '+str(var1)+', id= '+str(id(var1))
      var1 = 10
      print 'Within f and AFTER modification: var1= '+str(var1)+', id= '+str(id(var1))
  
  
  var = 5
  
  print '\n f - var1=10:'
  print 'BEFORE FUNCTION CALL: var= '+str(var)+', id= '+str(id(var))
  f(var)
  print 'AFTER FUNCTION: var= '+str(var)+', id= '+str(id(var))
  
  print '\n f2 - var1=1:'
  var = [4,3,1,6]
  print 'BEFORE FUNCTION CALL: var= '+str(var)+', id= '+str(id(var))
  f2(var)
  print 'AFTER FUNCTION: var= '+str(var)+', id= '+str(id(var))
  
  print '\n f3 - var1=10 again:'
  var = 7
  print 'BEFORE FUNCTION CALL: var= '+str(var)+', id= '+str(id(var))
  f3(var)
  print 'AFTER FUNCTION: var= '+str(var)+', id= '+str(id(var))
  
  print '\n f2 - var1=1 again:'
  var='a'
  print 'BEFORE FUNCTION CALL: var= '+str(var)+', id= '+str(id(var))
  f2(var)
  print 'AFTER FUNCTION: var= '+str(var)+', id= '+str(id(var))
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code> f - var1=10:
  BEFORE FUNCTION CALL: var= 5, id= 18089816
  Within f and BEFORE modification: var1= 5, id= 18089816
  Within f and AFTER modification: var1= 10, id= 18089696
  AFTER FUNCTION: var= 5, id= 18089816
  
   f2 - var1=1:
  BEFORE FUNCTION CALL: var= [4, 3, 1, 6], id= 23884720
  Within f and BEFORE modification: var1= [4, 3, 1, 6], id= 23884720
  Within f and AFTER modification: var1= 1, id= 18089912
  AFTER FUNCTION: var= [4, 3, 1, 6], id= 23884720
  
   f3 - var1=10 again:
  BEFORE FUNCTION CALL: var= 7, id= 18089768
  Within f and BEFORE modification: var1= 7, id= 18089768
  Within f and AFTER modification: var1= 10, id= 18089696
  AFTER FUNCTION: var= 7, id= 18089768
  
   f2 - var1=1 again:
  BEFORE FUNCTION CALL: var= a, id= 140350777144584
  Within f and BEFORE modification: var1= a, id= 140350777144584
  Within f and AFTER modification: var1= 1, id= 18089912
  AFTER FUNCTION: var= a, id= 140350777144584
  </code></pre>
  
  <p>I understand that the identity of an object is guaranteed to be unique during the its lifetime, and that two objects with non-overlapping lifetimes may have the same <code>id()</code> value. </p>
  
  <p>From that I understand that I can get the same <code>id()</code> during the execution of the code for different variables, but I am surprised that in my code the same <code>id()</code> values coincide also with the variable values.</p>
  
  <p>I mean that I always get the same <code>id()</code> value for <code>var1=10</code>. The same happens with the assignment <code>var1=1</code> that has its own <code>id()</code> value. Even doing this assignment in different functions returns the same <code>id()</code>.</p>
  
  <p>So my question is: 
  Is Python keeping a record of previous variables, values and identities even after their lifetimes have expired?</p>
  
  <p>If in the code there is a variable assignment with the same value as a previously expired variable, does Python check records of the previous expired variables in memory and give priority to use the same <code>id()</code> for the same memory values?</p>
  
  <p>I would like to understand a little bit more about <code>id()</code> values reuse and the memory management in a Python program.</p>