[Python-Dev] [Python-checkins] Python Regression Test Failures refleak (1) (original) (raw)

Tim Peters tim.peters at gmail.com
Wed Mar 15 07:42:24 CET 2006


[Thomas Wouters]

I did the same narrowing-down last week, and submitted a patch to add cycle-GC support to itertools.tee . It really needs it.

I agree.

Come to think of it, now that I remember how to properly do GC, I think the patch cuts some corners, but it solved the problem.

You mean because it didn't supply tp_clear? That's a funny one. Some people take pride in not supplying tp_clear unless it's absolutely necessary. For example, despite that tuples can be in cycles, the tuple type doesn't supply a tp_clear. This is "because" it's possible to prove that any cycle involving tuples must involve a non-tuple gc'ed type too, and that clearing the latter is always sufficient to break the cycles (which is all tp_clear needs to do: we just need that the aggregate of all tp_clear slots that are implemented suffice to break all possible cycles).

I never saw a point to that cleverness, though. It makes gc more obscure, and I'm not sure what it buys. Maybe the (typically teensy) bit of code needed to implement a tp_clear slot? That's all the (dubious) benefit I can think of.

Raymond is on it, anyway:

http://python.org/sf/1444398

You found it, you fix it :-)



More information about the Python-Dev mailing list