On 7 Jul 2014 19:22, "Andreas Maier" <andreas.r.maier@gmx.de> wrote:
>
> Thanks to all who responded.
>
> In absence of class-specific equality test methods, the default implementations revert to use the identity (=address) of the object as a basis for the test, in both Python 2 and Python 3.
>
> In absence of specific ordering test methods, the default implementations revert to use the identity (=address) of the object as a basis for the test, in Python 2. In Python 3, an exception is raised in that case.

In Python 2, it orders by type, and only then by id (which happens to be the address in CPython).

>
> The bottom line of the discussion seems to be that this behavior is intentional, and a lot of code depends on it.
>
> We still need to figure out how to document this. Options could be:
>
> 1. We define that the default for the value of an object is its identity. That allows to describe the behavior of the equality test without special casing such objects, but it does not work for ordering. Also, I have difficulties stating what constitutes that default case, because it can really only be explained by referring to the presence or absence of the class-specific equality test and ordering test methods.
>
> 2. We don't say anything about the default value of an object, and describe the behavior of the equality test and ordering test, which both need to cover the case that the object does not have the respective test methods.

The behaviour of Python 3's type system is fully covered by equality defaulting to comparing by identity, and ordering comparisons having to be defined explicitly. The docs at https://docs.python.org/3/reference/expressions.html#not-in could likely be clarified, but they do cover this (they just cover a lot about the builtins at the same time).

> It seems to me that only option 2 really works.

Indeed, and that's the version already documented.

Regards,
Nick.

>
>
> Comments and further options welcome.
>
> Andy
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com