Re: Python Tutorial Questions

Jim Roskind (jar@infoseek.com)
Fri, 29 Jul 1994 16:23:23 -0700

> From: jaap@sequent.com (Jaap Vermeulen)
> References: <watton-2207941525020001@132.226.104.125>
> Date: Thu, 28 Jul 94 23:19:13 GMT
>
> In <watton-2207941525020001@132.226.104.125> watton@atc.alcoa.com (John Watton) writes:
>
> >(1) Does Python have a garbage collector built in or do I have to
> >manage my own memory with the del() operator?
>
> Python uses reference counts, so memory is managed for most objects.
> You would need to use del() to break cycles.

The del() instruction has me confused, and this "easy" answer simply
supports my confusion. IF I have a "cycle", and the del() command can
"break that cycle" by doing something as simple as:

del(a)

then it seems to me that the exact same "cycle" can be broken by
doing:

a = None

I understand how reference counts work to achieve GC, and I don't see
the justification for a del() command when the existing stuff (my
example) works equally well. What am I missing?

Note I *can* justify the presence of the del() on other grounds, but I
*can't* for the life of me figure out why it comes up in GC
discussion. (Except that it sounds like "free()" from C, or "delete
..." from C++).

Thanks,

Jim

Jim Roskind
voice: 408.982.4469
fax: 408.986.1889
jar@infoseek.com