On Jun 2, 2014 10:41 PM, "Deb Wyatt" <codemon...@inbox.com> wrote:
> a_string = "This is a string"
> a_string is pointing to the above string
> now I change the value of a_string
> a_string = "This string is different"
> I understand that now a_string is pointing to a different string than it
was before, in a different location.
> my question is what happens to the original string??  Is it still in
memory somewhere, nameless?
> Thanks in advance,

If there are still any references being held to the original string, then
it will remain in memory. Otherwise, the memory used for it will be freed.
You can't rely on this happening immediately (although in CPython it does,
as long as the object is not part of a reference cycle), but it will happen

Reply via email to