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


Groups > comp.lang.python > #72463

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; '"this': 0.03; 'cpython': 0.05; 'memory.': 0.07; 'string': 0.09; 'does,': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'otherwise,': 0.22; 'string,': 0.24; 'question': 0.24; '&gt;': 0.26; 'references': 0.26; 'header:In- Reply-To:1': 0.27; 'subject:) ': 0.29; 'message- id:@mail.gmail.com': 0.30; '(although': 0.31; 'subject:the': 0.34; 'subject: (': 0.35; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'thanks': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'subject:"': 0.60; 'happen': 0.63; 'different': 0.65; 'subject:being': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=0IP32etznl58NdxD2nSBeVkQxHFz8V20xYzCex1RrXI=; b=L9wHnGePmO5OxcYt4upp0AbvrQTBxmmYL0Gf48dfcQ28oQKtlSSJDCckoWVRTK/Wb4 cSG9xYfY23VGk3/EbYKwKSxLZ3X2ZfZL/n2f0wsw9H2oXC31oaeaXhiBlZXUGm9Xuaa6 q3jr+ttqRDwl3uC8gEJ2gHFU+DHxmq5+aUjErnPk5yK+b45cg2VKporYrcDHFxoDrRcr nnhE7WmeBnSzTADe9dTAOWbnLMDFsaOkrhgSfRZiTLw6BTFd7k2anknR2b269WAGv+md 7W8C2Ev0P3XdrV0E9wyqpbrdaFaUEsrgghG/59xlOBHBGCz4bApByIzKKp1116II9/N4 MA5A==
MIME-Version 1.0
X-Received by 10.236.65.227 with SMTP id f63mr3892836yhd.13.1401771065192; Mon, 02 Jun 2014 21:51:05 -0700 (PDT)
In-Reply-To <CB9E0AA79B1.00000B26codemonkey@inbox.com>
References <CB9E0AA79B1.00000B26codemonkey@inbox.com>
Date Mon, 2 Jun 2014 22:51:05 -0600
Subject Re: can someone explain the concept of "strings (or whatever) being immutable"
From Ian Kelly <ian.g.kelly@gmail.com>
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=001a11c30d9a65b64304fae742fa
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10587.1401771067.18130.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1401771067 news.xs4all.nl 2841 [2001:888:2000:d::a6]:43278
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:72463

Show key headers only | View raw


[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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web