Can double-linked lists be implemented in python?

Aahz aahz at pythoncraft.com
Wed Apr 2 13:12:13 EST 2003


In article <b6f7ib$4rc09$1 at ID-139865.news.dfncis.de>,
Dave Kuhlman  <dkuhlman at rexx.com> wrote:
>
>But suppose that I *do* implement double linked lists.  I'll have two
>objects that point at each other, in other words circular references.
>
>In older versions of Python, circular references were not garbage
>collected.  Is this still true in Python 2.2 and 2.3?  Do I need to use
>the gc module to *enable* garbage collection?  Or, is not *disabling*
>it good enough?  Do I still need to worry about this?  And, suppose you
>tell me that circular references are collected but I don't believe you.
>How can I check?

There would only be a circular reference if the doubly-linked list were
not referred to from outside.  When all external references are deleted,
garbage collection will reap the cycle.  (Note that I'm not answering the
rest of your questions; you can find that info in the docs.)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

This is Python.  We don't care much about theory, except where it intersects 
with useful practice.  --Aahz, c.l.py, 2/4/2002




More information about the Python-list mailing list