Infinitely nested containers
ian.g.kelly at gmail.com
Fri Nov 21 18:13:44 CET 2014
On Thu, Nov 20, 2014 at 10:54 PM, Gill Shen <gillarete at gmail.com> 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.
More information about the Python-list