[Python-Dev] very slow compare of recursive objects
Guido van Rossum
guido@python.org
Mon, 20 Jan 2003 08:03:50 -0500
> Speaking of graceful approaches, I expect that this code:
>
> (v->ob_type->tp_as_mapping
> || (v->ob_type->tp_as_sequence
> && !PyString_Check(v)
> && !PyTuple_Check(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 tp_as_mapping 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 check_recursion'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/)