Linked Lists and Trees

Alex Martelli aleaxit at yahoo.com
Tue Oct 17 11:33:17 EDT 2000


"Aahz Maruch" <aahz at panix.com> wrote in message
news:8sfaal$igh$1 at panix3.panix.com...
> In article <8sb6f9$rgj$1 at news.nuri.net>,
> June Kim <junaftnoon at nospamplzyahoo.com> wrote:
> >
> >Can you refer me to,
> >"Any good and robust (in terms of memory management and speed)
> >implementation of general data structures like double-linked lists and
> >trees"?
>
> Although there are other ways, I usually just use a Python class to
> simulate a C record (with prev/next for lists and right/left for trees).
> That makes it easy to swipe algorithms.  Note that you'll need to be as
> careful as in C to free memory structures or you'll leak memory.

With Python 2's gc, you shouldn't leak memory unless your
class-instances have __del__ methods (if I understand
the issue correctly...) but might want to set gc to warn
you on collection (if you consider uncollected cycles a
bug in your code...).


Alex






More information about the Python-list mailing list