My question is with reference to this discussion here: Unnamed Python objects have the same id
Why is that these 2 range objects assigned to variables have "overlapping lifetimes"?
x = range(3)
y = range(3)
In what sense are they overlapping? If I delete variable x using the command: del x
then the range object associated with x is GC'd since there is no longer a reference to it. But range object associated with variable y is still present. So how are lifetimes overlapping?
Also, I am not very clear about when lifetimes overlap and when they do not. Can this be explained in some simple terms? Assume Python version 3.6.5.