Python vs Java garbage collection?

maney at pobox.com maney at pobox.com
Mon Dec 23 02:09:41 EST 2002


John Roth <johnroth at ameritech.net> wrote:
> I'm not certain I'd call this sloppy programming. It's a language
> design choice. What you seem to be saying is that the garbage
> collector shouldn't be required to call cleanup methods when it
> releases garbage objects.

No, what he's saying is that it's sloppy practice to rely on having
resources (other than memory) reclaimed by the invisible hand of the
garbage collector.  You seem to be under the misaprehension that Python
guarantees such timely finalization.

  Objects are never explicitly destroyed; however, when they become
  unreachable they may be garbage-collected. An implementation is
  allowed to postpone garbage collection or omit it altogether
                                -- Python language reference manual

> The trouble is, that subverts the entire rationalle behind
> garbage collection.

Well, no.  Garbage collection is a *memory* management tool.

> If the programmer has to determine when an object becomes garbage so
> it can be finalized properly, then we might as well just go back to
> malloc and free.

See, there, you just said it yourself: garbage collection is memory
management, not object finalization.  Or am I mistaken and free()
performs finalization these days?  <wink>



More information about the Python-list mailing list