A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-November/057870.html below:

[Python-Dev] Should the default equality operator compare valuesinstead of identities?

[Python-Dev] Should the default equality operator compare valuesinstead of identities? [Python-Dev] Should the default equality operator compare valuesinstead of identities?Noam Raphael noamraph at gmail.com
Wed Nov 2 22:18:58 CET 2005
On 11/2/05, Raymond Hettinger <raymond.hettinger at verizon.net> wrote:
> > Should the default equality operator compare valuesinstead of
> identities?
>
> No.  Look back into last year's python-dev postings where we agreed that
> identity would always imply equality.  There were a number of practical
> reasons.  Also, there are a number of places in CPython where that
> assumption is implicit.
>
Perhaps you've meant something else, or I didn't understand? Identity
implying equality is true also in value-based comparison. If the
default __eq__ operator compares by value, I would say that it would
do something like:

def __eq__(self, other):
    if self is other:
        return True
    if type(self) is not type(other):
        return False
    (compare the __dict__ and any __slots__, and if they are all ==,
return True.)

Noam
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4