In Interactive mode of python, When i say,
>>> mystr = 'abc'
we have object created in the current frame of type string
with content 'abc'
Now, If i change the binding of mystr
as shown below,
>>> mystr = 'def'
then, the name mystr
will bind to a new object with the content 'def'
.
We know that string are immutable objects, so object containing 'abc'
gets unaffected.
In my machine it works like this:
>>> mystr = 'abc'
>>> id(mystr)
30868568
>>> mystr = 'def'
>>> id(mystr)
36585632
>>> mystr = 'abc'
>>> id(mystr)
30868568
My question:
How does Python environment deal with object containing 'abc' after new binding, Will it purged?