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


Groups > comp.lang.python > #89827

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.061
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'python,': 0.02; 'cpython': 0.05; 'subject:Python': 0.06; 'lst': 0.09; 'python': 0.11; 'cleaned': 0.16; 'subject: \n ': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'creating': 0.23; 'necessary.': 0.24; "shouldn't": 0.24; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'message- id:@mail.gmail.com': 0.30; 'chase': 0.31; 'advice': 0.35; 'except': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'subject:data': 0.36; 'subject:?': 0.36; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'major': 0.40; 'manually': 0.60; 'subject:Can': 0.60; 'break': 0.61; "you're": 0.61; 'such': 0.63; 'more': 0.64; 'believe': 0.68; 'containing': 0.69; 'guaranteed': 0.75; 'subject:this': 0.83; '2015': 0.84; '3.4': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=xAE0ttSGLpDK/SCDnRaqf9EOut+gOy250ihjkgCyhio=; b=Swttbic30sQ1QK/y7XRPXqI7iRPBC8pr/PzjdhIFw31cEm/4IhlYNyAT6lIbWqod0h OBSzs8RtC0bGfl/wRjT97VD7f4yV0SxKDDJZcY1oNdtmVLbadgCoQPGpFTnDf7mdjjqW Fx508OtfC4FARRxzW+ewnOA1T+cwZHPQrG78pTs6BRTjBRBfJp6BFk//fZy4l+gnpLKX NabGnt35sQm7+i5lZjDfz+IC1fmMHDEJH/7lSuPXSEko3M+UcpzzjKYvgDBGQ8pmRfmD uAUm4+njPjOOkuAn6QdGokzXg+bcEOfslmVVrAbsnnhtfFxpEgIaOSwvFofip75Yeak2 4dqA==
X-Received by 10.107.136.89 with SMTP id k86mr19907145iod.63.1430628221645; Sat, 02 May 2015 21:43:41 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <20150502151723.3a36e33b@bigbox.christie.dr>
References <387ac520-9da3-411a-a3b8-b326e1e8a2c0@googlegroups.com> <20150502151723.3a36e33b@bigbox.christie.dr>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Sat, 2 May 2015 22:43:01 -0600
Subject Re: Inner workings of this Python feature: Can a Python data structure reference itself?
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.44.1430628229.12865.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1430628229 news.xs4all.nl 2880 [2001:888:2000:d::a6]:39828
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:89827

Show key headers only | View raw


On Sat, May 2, 2015 at 2:17 PM, Tim Chase <python.list@tim.thechases.com> wrote:
> If you know that you're creating such cyclical structures, it's best
> to manually unlink them before freeing them:
>
>   lst = []
>   lst.append(lst) # create the cycle
>   lst[:] = []   # break the cycle
>   # or lst.remove(lst) # though this takes more care
>   del lst

In general, this shouldn't be necessary. I believe that reference
cycles are guaranteed to be cleaned up in all major implementations of
Python, except that in CPython prior to version 3.4 reference cycles
containing objects with finalizers would not be collected. So the
better advice would be "don't use finalizers in reference cycles if
you need compatibility with Python 3.3 or earlier."

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


Thread

Inner workings of this Python feature: Can a Python data structure reference itself? vasudevram <vasudevram@gmail.com> - 2015-05-02 13:02 -0700
  Re: Inner workings of this Python feature: Can a Python data structure reference itself? Tim Chase <python.list@tim.thechases.com> - 2015-05-02 15:17 -0500
    Re: Inner workings of this Python feature: Can a Python data structure reference itself? vasudevram <vasudevram@gmail.com> - 2015-05-02 14:07 -0700
    Re: Inner workings of this Python feature: Can a Python data structure reference itself? Cecil Westerhof <Cecil@decebal.nl> - 2015-05-02 23:06 +0200
      Re: Inner workings of this Python feature: Can a Python data structure reference itself? MRAB <python@mrabarnett.plus.com> - 2015-05-03 00:07 +0100
      Re: Inner workings of this Python feature: Can a Python data structure reference itself? Tim Chase <python.list@tim.thechases.com> - 2015-05-02 20:57 -0500
      Re: Inner workings of this Python feature: Can a Python data structure reference itself? Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-02 22:29 -0600
  Re: Inner workings of this Python feature: Can a Python data structure reference itself? Tim Chase <python.list@tim.thechases.com> - 2015-05-02 15:10 -0500
  Re: Inner workings of this Python feature: Can a Python data structure reference itself? Terry Reedy <tjreedy@udel.edu> - 2015-05-02 19:17 -0400
    Re: Inner workings of this Python feature: Can a Python data structure reference itself? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-03 21:10 +1000
    Re: Inner workings of this Python feature: Can a Python data structure reference itself? vasudevram <vasudevram@gmail.com> - 2015-05-03 05:59 -0700
      Re: Inner workings of this Python feature: Can a Python data structure reference itself? vasudevram <vasudevram@gmail.com> - 2015-05-03 06:05 -0700
      Re: Inner workings of this Python feature: Can a Python data structure reference itself? Chris Angelico <rosuav@gmail.com> - 2015-05-03 23:08 +1000
        Re: Inner workings of this Python feature: Can a Python data structure reference itself? vasudevram <vasudevram@gmail.com> - 2015-05-03 08:46 -0700
  Re: Inner workings of this Python feature: Can a Python data structure reference itself? Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-02 22:43 -0600
  Re: Inner workings of this Python feature: Can a Python data structure reference itself? Chris Angelico <rosuav@gmail.com> - 2015-05-03 15:46 +1000
  Re: Inner workings of this Python feature: Can a Python data structure reference itself? vasudevram <vasudevram@gmail.com> - 2015-05-03 03:52 -0700

csiph-web