Circular references (was: Defining VCL-like framework for Py

William Tanksley wtanksle at dolphin.openprojects.net
Tue May 25 14:21:03 EDT 1999


On Mon, 24 May 1999 23:34:19 -0500, Gordon McMillan wrote:
>William Tanksley wrote:

>> On Thu, 20 May 1999 15:00:03 -0500, Gordon McMillan wrote:

>> >Despite these drawbacks, I generally prefer ref counting to garbage
>> >collection. GC is generally nondeterminant - you know it _will_
>> >happen, but you have no idea _when_. So if your objects have some
>> >kind of outside resource open, you need to have a special free()
>> >method anyway instead of relying on freeing it in the destructor. 

>> I prefer refcounting as well -- it feels like a simpler, more
>> controlled solution.  It's not particularly "more deterministic",
>> though; any assignment to a pointer can result in a massive flurry
>> of deallocations :).  

>I said "deterministic", not "easily predicted" <wink>.

Both are deterministic, neither one is easily predicted.  And you said
"nondeterminant", not "deterministic".  I do not think that word means
what you think it means ;-).

>> Ken Thompson recently mentioned the way they
>> do GC in Inferno.  They keep reference counts, and also do a lazy
>> generational scan every once in a while.  The reference counting
>> controls the vast majority of the garbage; the lazy scan eventually
>> finds and cleans up the occasional cycle, without spending too much
>> time or causing too many other problems. It looks like a nice
>> solution to the problem of cycles.

>I read that interview, too, and was very intrigued by that section.

It _seems_ that it might be easier to implement portably.

>> >I realize many people feel strongly the other way, and I'm not going 
>> >to fight about it. Neither solution is perfect. I'm just stating my 
>> >preference.

>> Well, I agree -- but I would like to remove the problem of cycles. 
>> It would just be one less thing to complicate my Python code.

>Maybe we can fight about something else then?

I'm certain we'll find something.  Haven't we always?

>> I've tried to find other methods, but nothing simple seems to work
>> well -- everything requires some pretty nasty complications and
>> overhead.

>In some languages, circular references make it hard to compile, let 
>alone clean up nicely.

You're kidding!  How does that work?

>there's-a-hole-in-the-bucket-ly y'rs
>- Gordon

no-there's-a-bucket-around-the-hole-ly yr's

-- 
-William "Billy" Tanksley
"But you shall not escape my iambics."
           -- Gaius Valerius Catullus




More information about the Python-list mailing list