title: How does `is` work in the case of ephemeral objects sharing the same memory address?
body: <p>Note that this question might be (is?) specific to CPython.</p>
  
  <p>Say you have some list, and check copies of the list for identity against each other:</p>
  
  <pre><code>&gt;&gt;&gt; a=list(range(10))
  &gt;&gt;&gt; b,c=a[:],a[:]
  &gt;&gt;&gt; b is c
  False
  &gt;&gt;&gt; id(b), id(c)
  (3157888272304, 3157888272256)
  </code></pre>
  
  <p>No great shakes there. But if we do this in a more ephemeral way, things might seem a bit weird at first:</p>
  
  <pre><code>&gt;&gt;&gt; a[:] is a[:]
  False  # &lt;- two ephemeral copies not the same object (duh)
  &gt;&gt;&gt; id(a[:]),id(a[:])
  (3157888272544, 3157888272544)   # &lt;- but two other ephemerals share the same id..? hmm....
  </code></pre>
  
  <p>...until we recognize what is probably going on here. I have not confirmed it by looking at the CPython implementation (I can barely read c++ so it would be a waste of time, to be honest), but it at least seems obvious that even though two objects have the same id, CPython is smart enough to know that they aren't the same object.</p>
  
  <p>Assuming this is correct, my question is: what criteria is CPython using to determine whether the two ephemeral objects are the not the same object, given that they have the same id (presumably for efficiency reasons- see below)? Is it perhaps looking at the time it was marked to be garbage collected? The time it was created? Or something else...?</p>
  
  <p>My theory on <em>why</em> they have the same id is that, likely, CPython knows an ephemeral copy of the list was already made and is waiting to be garbage collected, and it just efficiently re-uses the same memory location. It would be great if an answer could clarify/confirm this as well.</p>