[Python-Dev] iterzip()

Tim Peters tim.one@comcast.net
Mon, 29 Apr 2002 19:36:10 -0400

> Isn't this a case of "knowing your application"?  IOW, you're doing
> something that the gc isn't well-tuned to handle, by default.  That's
> why we expose the its operation through the gc module -- so you can
> take explicit steps for the hotspots in your application.

The difficulty is with apps that grow a lot of long-lived containers that
aren't trash and don't even contain cycles.  There's no bound on how often
they'll get crawled over looking for trash that ain't there, and the more of
those you grow the longer it takes to look at them.  When a gen2 collection
doesn't find any trash, it should probably become less eager to try looking
at the same stuff yet again.  Adding more generations could have a similar
good effect.

Half of a shadow of an idea:  at least in my code, it's common to have
gazillions of tuples, and they almost always contain just strings and
numbers.  Since they're immutable, they'll never contain anything else.  So
they could get unlinked from cyclic gc entirely without ill effect (it's not
possible that they could ever be in a cycle).  Perhaps a gen2 collection
could learn something about this and automagically untrack them.