[Python-Dev] Re: very slow compare of recursive objects

Tim Peters tim.one@comcast.net
Mon, 20 Jan 2003 16:50:14 -0500

The OP added a cute example to


It's a recursive object that should compare equal to itself if and only if
it does not compare equal to itself -- the Russell's Paradox of Python
comparisons.  As things stand, whether a==a (for this object) returns True
or False depends on the parity (odd or even) of object.c's NESTING_LIMIT.

I vote "give up".  The graph isomorphism business is cute but has no
practical application I've ever seen.  Even without the paradoxes, the
2-element list example takes about 4 seconds to return True now, and I
estimate a 3-element list would take 3-4 hours, and a 4-element list about
48 days.  Python isn't checking for KeyboardInterrupt during this, so
killing the process is the only way to stop it.  I'd rather raise a "can't
compare recursive objects" exception as soon as recursion is detected.