Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.041 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'languages.': 0.04; 'back.': 0.09; 'python': 0.11; 'all?': 0.16; 'tighter': 0.16; 'window;': 0.16; 'wrote:': 0.18; 'slightly': 0.19; 'thu,': 0.19; 'widget': 0.19; 'references': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'probably': 0.32; 'implemented': 0.33; 'common': 0.35; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'are,': 0.36; 'useful': 0.36; 'example,': 0.37; 'list': 0.37; 'nov': 0.38; 'window': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; '20,': 0.68; 'normal.': 0.68; 'containing': 0.69; 'behavior': 0.77 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=uPuTTMFFOaPZBxOniqpwkebe01l11oEeVqEQoks8aKI=; b=h5txCCzMNxLY7uCut4HR/k4mapsiezwenCSdmU4+jioAOIYE7gx0aylhGsPgy3Pay1 7GiT3KcsvNjOVcjAtXTowtTEefJZmAycpEYFE1AWIDXiFgTJ9uBg5pMAPGhX8YPUkEDN OweGnF5kD8A8luH7JLiFsyecXNUzohaPS2ovD3Z+6tmMPAgdvQT858PLxwOF5enHVemZ dHIF6pn53K6axDHGRYhtKI73OmZD0Co59LXFu5BQJRxZ667HaO1VUMNIiVeIipEZmdOe /b8OLowy1C8ju4BxW1ahWPgkBHxETFMmUx9AG0aJjo8wSgL4ROdohqohrLyyZKPRx0RE WYEQ== X-Received: by 10.70.102.234 with SMTP id fr10mr8779299pdb.145.1416590064728; Fri, 21 Nov 2014 09:14:24 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <931d12c0-12b3-4278-a9b9-1e2c32f138b3@googlegroups.com> References: <931d12c0-12b3-4278-a9b9-1e2c32f138b3@googlegroups.com> From: Ian Kelly Date: Fri, 21 Nov 2014 10:13:44 -0700 Subject: Re: Infinitely nested containers To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416590068 news.xs4all.nl 2954 [2001:888:2000:d::a6]:36371 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81229 On Thu, Nov 20, 2014 at 10:54 PM, Gill Shen wrote: > How is this behavior implemented under the hood? And why is this allowed at all? Is it just a curiosity or can you do something useful with it? Reference cycles are common in Python and other OO languages. For example, adding a widget to a window; the window contains references to its child widgets, and it's probably useful for the widgets to know what their parents are, so they would hold references back. A list containing itself is similarly a reference cycle. I don't know off-hand of any use for this specific case, but it's just a slightly tighter cycle than normal.