Misc questions about type objects and Python 3.0
david at no.westcontrol.spam.com
Tue Oct 8 14:33:25 CEST 2002
"Simon Brunning" <SBrunning at trisystems.co.uk> wrote in message
news:mailman.1034073671.12754.python-list at python.org...
> > From: David Brown [SMTP:david at no.westcontrol.spam.com]
> > > 2. If it isn't (I'm guessing it will be), is it the plan to keep
> > > reference counting? It seems to me that getting rid of reference
> > > counting might be the first step to getting rid of the GIL.
> > First, I would think that removing reference counting would wildly
> > the way Python works (correct me if I'm wrong here - I program with
> > Python,
> > but I haven't studied its implementation). I don't see how you can get
> > efficient garbage collection without some sort of reference counting.
> Jython doesn't use reference counting and it's hardly *wildly* different
> from CPython. Subtly different, yes, but you don't notice the difference
> very often, unless you are prone to de-referencing open files, or that
> of thing.
How does the garbage collection work then? Somehow you have to keep track
of whether an object is still in use or not. (Again, correct me if I'm
wrong here). Every time a reference is created to an object in CPython, the
reference count is incremented, when a reference is removed it is
decremented - if the count is 0, the object is no longer accessible and can
therefore be collected on the next garbage collection pass. As far as I
know, the only other way to do this is to regularly scan through all current
pointers to see what's in use - if there are any objects around that aren't
pointed to, they can be garbage collected. This has got to be a much less
efficient method. In JPython, presumably it is the underlying JVM that does
the garbage collection - maybe it uses reference counting even though the
Jython layer doesn't have to deal with it?
More information about the Python-list