Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72463 > unrolled thread

Re: can someone explain the concept of "strings (or whatever) being immutable"

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2014-06-02 22:51 -0600
Last post2014-06-02 22:51 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: can someone explain the concept of "strings (or whatever) being immutable" Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-02 22:51 -0600

#72463 — Re: can someone explain the concept of "strings (or whatever) being immutable"

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-06-02 22:51 -0600
SubjectRe: can someone explain the concept of "strings (or whatever) being immutable"
Message-ID<mailman.10587.1401771067.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

On Jun 2, 2014 10:41 PM, "Deb Wyatt" <codemonkey@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
eventually.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web