[Baypiggies] Frequently Argued Objections

Aahz aahz at pythoncraft.com
Fri Jun 20 05:47:39 CEST 2008


On Thu, Jun 19, 2008, Seth Friedman wrote:
>
> - How do I trust the garbage collection isn't doing weird things along the
> lines of the stop-the-world collector default in some versions of Java?
> 
> Again here, I'd love to learn more about how Python frees memory structures
> in detail, but don't really know how/where.    I've worked with Java enough
> to be (in my opinion) healthily paranoid, I haven't run into problems with
> this in Python, but I would love some understanding of what's going on under
> the covers sufficient to believe it's not just a matter of time, e.g.
> growing complexity of my code, until I start seeing utterly bizarre
> behavior.   I prefer to understand special-care-and-feeding cases up front
> and avoid them in design, rather than end up with a pile of years-old code I
> have to maintain, that only shows oddities of a language at the point where
> the complexity factor is high.

Python uses reference counting backed by GC (GC is only used to break
cycles of mutually-referring objects with no external references pointing
in).  Generally speaking, the only time you'll see a "stop-the-world"
collection is when you delete e.g. a dictionary with millions of
elements, each key/value pair of which is a moderate-sized string with
only the dict refering to the string (and that's all reference counting,
not GC).  It's possible to provoke GC into pathological behavior, but it
usually takes work.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"as long as we like the same operating system, things are cool." --piranha


More information about the Baypiggies mailing list