[Python-Dev] very slow compare of recursive objects (original) (raw)

Guido van Rossum guido@python.org
Mon, 20 Jan 2003 08:03:50 -0500


Speaking of graceful approaches, I expect that this code:

(v->obtype->tpasmapping || (v->obtype->tpassequence && !PyStringCheck(v) && !PyTupleCheck(v)))) { no longer does what it intended to do for tuples. Tuples can't be recursive,

Oh yes they can be:

L = [] t = (L, L) L.append(L)

so it intended to exempt tuples from the recursive-compare machinery. But Michael Hudson added a non-NULL tpasmapping slot to tuples in rev 2.65 of tupleobject.c, so tuples are no longer exempted by the recursive-compare gimmick. That makes the problem in 2.3 worse than it used to be (although it's never been zippy, due to clearing inprogress dict entries while they're still potentially useful). So all the hacks I added (in my ugly patch) to keep checkrecursion's tuple operations out of this code would be better done by restoring the "don't look at tuples at all" intent of the code above.

--Guido van Rossum (home page: http://www.python.org/~guido/)