[Patches] [ python-Patches-825639 ] let's get rid of cyclic object comparison

SourceForge.net noreply at sourceforge.net
Sun Oct 26 13:19:15 EST 2003


Patches item #825639, was opened at 2003-10-17 17:49
Message generated for change (Comment added) made by arigo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=825639&group_id=5470

Category: Core (C code)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Armin Rigo (arigo)
Assigned to: Nobody/Anonymous (nobody)
Summary: let's get rid of cyclic object comparison

Initial Comment:
Comparison of objects with recursive references is a
cool feature but it leaves too many questions open and
feels too much like a "do-what-i-mean" hack.

Attached patch casts it into the obscure world of CVS
history.

On the positive side, the patch contributes a
Py_EnterRecursiveCall()/Py_LeaveRecursiveCall() pair of
functions to the C API, to use at any point where an
infinite C-level recursion could occur. This is now
used by:

eval_frame()
PyObject_Compare()
PyObject_RichCompare()
instance_call()

and maybe it should be extended to cPickle.c, which has
its own notion of maximum nesting as well.

The diff also changes the tests to expect a
RuntimeError when comparing nested structures.

----------------------------------------------------------------------

>Comment By: Armin Rigo (arigo)
Date: 2003-10-26 18:19

Message:
Logged In: YES 
user_id=4771

Another version of the patch.  This one is quite faster --
I'm measuring the performance of:

a = [5] * 1000
b = [a] * 1000
b == b

for which test is appears now to have no measurable penalty.
 The drawback of this patch is a few extra obscure macros in
ceval.h.  Read the new comment in ceval.c for the idea.

----------------------------------------------------------------------

Comment By: Armin Rigo (arigo)
Date: 2003-10-23 11:13

Message:
Logged In: YES 
user_id=4771

Ok.  Before I reply to python-dev let me point out that I
tried not to weaken any test.  I guess you thought I just
removed some tests, because I indeed usually replaced a
group of self.assertXxx() lines with a smaller number of
assertions, but as far as I can tell they all test the
structure as much as the original assertions, and sometimes
even more.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2003-10-19 18:41

Message:
Logged In: YES 
user_id=21627

I think the patch needs to be discussed on python-dev to get
a chance to be accepted. It should also be accompanied with
a more elaborate rationale, and a guideline on how
applications that rely on the feature could detect the
change, and how those applications need to be updated. 

For example, I find the change to the pickle tester
unacceptable: you can't just drop the structural-equivalence
test, since it is the primary purpose of this test to
establish structural equivalence. So perhaps you should put
a custom structural-equivalence algorithm into pickletester,
and replace the assertEquals with that.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=825639&group_id=5470



More information about the Patches mailing list