[issue6970] Redundant calls made to comparison methods.
Mark Dickinson dicki...@gmail.com added the comment: Committed to py3k in r76304. Leaving trunk alone, as Brett suggested. -- resolution: - fixed stage: commit review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6970 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6970] Redundant calls made to comparison methods.
Mark Dickinson dicki...@gmail.com added the comment: Assigning to myself so this doesn't get forgotten. -- assignee: - mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6970 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6970] Redundant calls made to comparison methods.
Mark Dickinson dicki...@gmail.com added the comment: Here's a patch for py3k. I'd appreciate it if some other committer could check it for sanity. -- keywords: +patch Added file: http://bugs.python.org/file14967/issue6970.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6970 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6970] Redundant calls made to comparison methods.
Changes by Mark Dickinson dicki...@gmail.com: -- keywords: +needs review -patch stage: needs patch - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6970 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6970] Redundant calls made to comparison methods.
New submission from Mark Dickinson dicki...@gmail.com: Here's some strange behaviour in py3k: newton:py3k dickinsm$ ./python.exe Python 3.2a0 (py3k:75015, Sep 22 2009, 16:25:12) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type help, copyright, credits or license for more information. class A: ... def __eq__(self, other): ... print(In A.__eq__, self, other) ... return NotImplemented ... class B: ... def __eq__(self, other): ... print(In B.__eq__, self, other) ... return NotImplemented ... A() == B() In A.__eq__ __main__.A object at 0x34d030 __main__.B object at 0x448210 In B.__eq__ __main__.B object at 0x448210 __main__.A object at 0x34d030 In B.__eq__ __main__.B object at 0x448210 __main__.A object at 0x34d030 In A.__eq__ __main__.A object at 0x34d030 __main__.B object at 0x448210 False I'd expect to see only one call to A.__eq__ and one call to B.__eq__. The cause seems to be that: - slot_tp_richcompare (in typeobject.c) makes two calls to half_richcompare, one with the original arguments and one with reverse arguments, *and* - do_richcompare (in object.c) also makes two calls to the tp_richcompare slot; again, one with the original arguments and one with the reversed arguments. I tried removing the second block of slot_tp_richcompare (still in py3k); make and make test succeeded without any problems. Removing this block does change behaviour though, so probably should not happen until 3.2, given that no-one appears to have reported the current behaviour actually causing any problems. The duplicate calls also exist in 2.x; figuring out a solution there (and being sure that the solution does the right thing) looks complicated, thanks to all the rich-compare/three-way-compare interactions. -- components: Interpreter Core messages: 93000 nosy: mark.dickinson severity: normal stage: needs patch status: open title: Redundant calls made to comparison methods. type: behavior versions: Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6970 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6970] Redundant calls made to comparison methods.
Mark Dickinson dicki...@gmail.com added the comment: And here's an example from trunk: Python 2.7a0 (trunk:75012M, Sep 22 2009, 11:16:39) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type help, copyright, credits or license for more information. class A(object): ... def __eq__(self, other): ... print A.__eq({!r}, {!r}).format(self, other) ... return NotImplemented ... A() == A() A.__eq(__main__.A object at 0x39f670, __main__.A object at 0x39f610) A.__eq(__main__.A object at 0x39f610, __main__.A object at 0x39f670) A.__eq(__main__.A object at 0x39f670, __main__.A object at 0x39f610) A.__eq(__main__.A object at 0x39f610, __main__.A object at 0x39f670) A.__eq(__main__.A object at 0x39f610, __main__.A object at 0x39f670) A.__eq(__main__.A object at 0x39f670, __main__.A object at 0x39f610) False -- nosy: +cjw296 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6970 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6970] Redundant calls made to comparison methods.
Brett Cannon br...@python.org added the comment: I say fix it in 3.2 and don't worry about 2.x unless you really want to. As you said, it's rather tricky to untangle all of that and no one has complained yet. Plus it is a semantic change. -- nosy: +brett.cannon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6970 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com