Python complaints

James Logajan JamesL at Lugoj.Com
Thu Nov 25 15:30:27 EST 1999


Michael Hudson wrote:
> 
> James Logajan <JamesL at Lugoj.Com> writes:
> 
> > Sorry, but I think the price paid for "true" GC is too high for the
> > small number of programs that benefit from this. Perhaps one should
> > learn to clean up after oneself when cycles are expected.
> 
> While I'm inclined to agree that the loss of simplicity accompanied by
> inclusion of a true GC is too high a price to pay, "Perhaps one should
> learn to clean up after oneself when cycles are expected" is a
> ridiculous statement.

Oh yeah? Well yer mudder wears army boots! Seriously though, the price I am
talking about has absolutely nothing to do with simplicity. It has to do
with the fact that languages such as Java that have "true" GC are
non-deterministic in their execution times because GC can cause execution
pauses in the VM at unpredictable times. This makes Java unacceptable for a
large number of real-world applications that I have been involved in lately.
("I'm sorry, but your 911 call can not go through for another 20 seconds
while our Java VM garbage collects 1GB of memory on the switch.") I have
recommended Python over Java in at least one environment because of Python's
deterministic approach to memory management. Had Python not had that, I
suppose we would have gone with some other scripting language or even
designed our own (gak!).

> 
> Suppose I want to represent some chain like structure where I can
> reach any element from any other. This is not an outrageous request,
> to my mind. Clearly the easiest solution is to use some kind of doubly
> linked list, but the naïve implementation of this will lead to a
> cyclic structure. So then either (a) you have to supply an explicit
> .finalize() method or (b) you have to hack around mightily using
> __getattr__ producing a solution that is slow and fragile. Neither of
> these is at all satisfactory to my mind. Using DC's Aquisition classes
> can help, but it's still an advanced technique that required to solve
> a problem that looks incredibly simple.

Thanks for the example of that small class of programs that *might* benefit
from "true" GC. I should point out that I have written Python programs with
cycles and it wasn't that horrid an experience making sure memory was
recovered. In my humble opinion, every experienced programmer should have
learned how to manage memory in languages like C, C++, etc. The problem with
implementing "true" GC in any language is that all known solutions (as far
as I know) make trade-offs that may be unacceptable for an important set of
applications.

(If my knowledge of "true" GC is outdated, I'd love to hear what current
solutions are!)




More information about the Python-list mailing list