[Tutor] python memory management

monikajg at netzero.net monikajg at netzero.net
Sat Sep 3 23:21:25 EDT 2016


Thank you all for your explanations. I really enjoy learning about things like that.
Monika

---------- Original Message ----------
From: Alan Gauld via Tutor <tutor at python.org>
To: zakaria <zemmoura.khalil at gmail.com>, tutor at python.org
Subject: Re: [Tutor] python memory management
Date: Sun, 4 Sep 2016 01:22:27 +0100

On 03/09/16 23:20, zakaria wrote:
> Is there any practical usage of using reference cycling?

There are a (very) few cases where data structures require the
creation of cyclic references. One example I've used is in
managing comms networks where nodes are multiply and/or
cyclically linked and you need to build those linkages into
your data model. In those cases you need to manage the
cleanup yourself.

But most cyclic references occur by accident, the programmer
probably didn't intend them to exist but it just so happened that
one object points to another which happens to point at another
which in turn points at the first. The cycle can span many objects.
Think of a directory tree where a deeply nested node has a link
pointing back at a root level node. But the root also indirectly
points at that low level node by means of the tree structure...

As a specific example, It often happens in GUIs where widgets
hold references to other widgets higher in the widget
parent/child tree.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

____________________________________________________________
Unlock Visions (Sponsored by Content.Ad)
1 Odd Method 'Restores' Your 20/20 Vision. Try This
http://thirdpartyoffers.netzero.net/TGL3241/57cb93756ab9c13757ae2st02duc


More information about the Tutor mailing list