This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: built-in method .__cmp__
Type: Stage:
Components: Interpreter Core Versions:
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: arigo Nosy List: arigo
Priority: normal Keywords:

Created on 2005-11-07 08:55 by arigo, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg26811 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2005-11-07 08:55
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

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
msg26812 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2005-12-01 10:40
Logged In: YES 

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
msg26813 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-04-21 16:41
Logged In: YES 

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

If nobody object I will check in a fix that makes
instance methods and built-in instance methods compare
their 'self' recursively.
msg26814 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-06-08 10:57
Logged In: YES 

Checked in as r46739.
Date User Action Args
2022-04-11 14:56:13adminsetgithub: 42561
2005-11-07 08:55:31arigocreate