Issue 1350060: built-in method .cmp (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/42561

classification

Title: built-in method .__cmp__
Type: Stage:
Components: Interpreter Core Versions:

process

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 _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.
msg26812 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2005-12-01 10:40
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'.
msg26813 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-04-21 16:41
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.
msg26814 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-06-08 10:57
Logged In: YES user_id=4771 Checked in as r46739.
History
Date User Action Args
2022-04-11 14:56:13 admin set github: 42561
2005-11-07 08:55:31 arigo create