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.

Author terry.reedy
Recipients andymaier, chris.jerdonek, cvrebert, docs@python, ezio.melotti, mark.dickinson, mikehoy, rhettinger, terry.reedy
Date 2014-07-04.19:24:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1404501847.28.0.512469831564.issue12067@psf.upfronthosting.co.za>
In-reply-to
Content
In py3, *everything* is an instance of class object. This makes like simple than in 2.x. The default comparison rules are set by the rich comparison methods of object. 'By experiment' meant by experiments with instances of object, which use those default methods, rather than by inspection of the relevant .c source code. Instances of subclasses taht do not override the defaults would act the same. Here is what seem to be the default code, from object.c, do_compare.  It verifies what I said (v, w are pointers, which represent identity):

    /* If neither object implements it, provide a sensible default
       for == and !=, but raise an exception for ordering. */
    switch (op) {
    case Py_EQ:
        res = (v == w) ? Py_True : Py_False;
        break;
    case Py_NE:
        res = (v != w) ? Py_True : Py_False;
        break;
    default:
        /* XXX Special-case None so it doesn't show as NoneType() */
        PyErr_Format(PyExc_TypeError,
                     "unorderable types: %.100s() %s %.100s()",
                     v->ob_type->tp_name,
                     opstrings[op],
                     w->ob_type->tp_name);
        return NULL;
    }
    Py_INCREF(res);
    return res;

Subclasses can and ofter do override the default methods. In particular, the number subclasses compare by value, across number types.
History
Date User Action Args
2014-07-04 19:24:07terry.reedysetrecipients: + terry.reedy, rhettinger, mark.dickinson, ezio.melotti, cvrebert, chris.jerdonek, docs@python, mikehoy, andymaier
2014-07-04 19:24:07terry.reedysetmessageid: <1404501847.28.0.512469831564.issue12067@psf.upfronthosting.co.za>
2014-07-04 19:24:07terry.reedylinkissue12067 messages
2014-07-04 19:24:06terry.reedycreate