title: If we change object's reference in Python, why does it sometimes change the id (memory location) of object?
body: <p>I was trying to implement a node for linked list and faced the following issue: When I assign a new object to <code>m2</code>and then assign the new variable <code>c</code> to the old object associated with <code>m2</code> it gives back the same id.</p>
  <pre><code>class Node:
      def __init__(self,dataval=None):
          self.val = dataval ##Int
          self.nextval = None ##Node
  class SLinkedList:
      def __init__(self,headval=None):
          self.headval = headval ##Node
  
  m2 = Node(4)
  print(id(m2)) # Returns 2309784010704
  m2 = Node(5)
  c = Node(4) # Assigning same object as previously with m2
  print(id(c)) # Returns 2309784010704 which is same as id of m2
  </code></pre>
  <p>But if I don't change value of <code>m2</code> as shown below then it shows different id locations of <code>m2</code> and <code>c</code>.</p>
  <pre><code>class Node:
      def __init__(self,dataval=None):
          self.val = dataval ##Int
          self.nextval = None ##Node
  class SLinkedList:
      def __init__(self,headval=None):
          self.headval = headval ##Node
  
  m2 = Node(4)
  print(id(m2)) # Returns 2582642884560
  
  c = Node(4)
  print(id(c)) # Returns 2582642884320 which is not same as id of m2 
  </code></pre>
  <p>I was not able to know the reason why in first code, id of <code>c</code> is same as previous id of <code>m2</code> rather than not assigning it a new memory location.</p>