[Python-Dev] Detecting tp_compare / tp_richcompare from Python

Guido van Rossum guido at python.org
Thu Nov 8 18:59:35 CET 2012


In Python, you can write

if C.__eq__ == object.__eq__:
    print('class C does not override __eq__')

Does that help?

On Thu, Nov 8, 2012 at 9:55 AM, Tres Seaver <tseaver at palladion.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 11/08/2012 12:38 PM, Guido van Rossum wrote:
>> Well, the default behavior has changed to raise an exception when
>> using <, <=, >, >=; i.e., inequalities do not have a default
>> implementation at all. Perhaps that is enough for your purpose? ==
>> and != still compare by pointer, but you're primarily interested in
>> ordering her, right?
>
> The b-search algorithm needs ordering on keys, but also meaningful
> (non-identity) equality.
>
>
> Tres.
> - --
> ===================================================================
> Tres Seaver          +1 540-429-0999          tseaver at palladion.com
> Palladion Software   "Excellence by Design"    http://palladion.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
>
> iEYEARECAAYFAlCb8iMACgkQ+gerLs4ltQ6WOACgwERmICWr80qnEoOVVLQtFwTH
> ttAAnAt4An0dPjaRuZyJlDAUGzH0CS7B
> =u2mG
> -----END PGP SIGNATURE-----



-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list