[ python-Bugs-1350060 ] built-in method .__cmp__

SourceForge.net noreply at sourceforge.net
Fri Apr 21 18:41:06 CEST 2006


Bugs item #1350060, was opened at 2005-11-07 08:55
Message generated for change (Comment added) made by arigo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1350060&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Armin Rigo (arigo)
Assigned to: Armin Rigo (arigo)
Summary: built-in method .__cmp__

Initial Comment:
Bound methods of built-in objects have a strange
__cmp__/__hash__ combination: they compare equal only
if their __self__ are identical, but they hash based
on the hash of __self__ instead of its
_Py_HashPointer().

Built-in methods should consistently be based on the
identity *or* the equality of __self__.  For reference,
regular instance methods are based on the equality.  So
I propose to fix built-in method objects in the same
way.

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

>Comment By: Armin Rigo (arigo)
Date: 2006-04-21 16:41

Message:
Logged In: YES 
user_id=4771

I've just been bitten by this problem.  It's an arguably
reasonable use case about why instance methods should
work like immutable containers (they are immutable,
after all) in the sense that equality should be
structural.

If nobody object I will check in a fix that makes
instance methods and built-in instance methods compare
their 'self' recursively.

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

Comment By: Armin Rigo (arigo)
Date: 2005-12-01 10:40

Message:
Logged In: YES 
user_id=4771

Sorry, my mistake: regular instance methods behave like
built-in methods.  They are both based on the identity of
their 'self' but use its hash to compute their own hash.

This bug report is thus only about why should the hash of
methods and built-in methods depend on the hash of their
'self'.

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

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


More information about the Python-bugs-list mailing list