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 <>
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;
    case Py_NE:
        res = (v != w) ? Py_True : Py_False;
        /* XXX Special-case None so it doesn't show as NoneType() */
                     "unorderable types: %.100s() %s %.100s()",
        return NULL;
    return res;

Subclasses can and ofter do override the default methods. In particular, the number subclasses compare by value, across number types.
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: <>
2014-07-04 19:24:07terry.reedylinkissue12067 messages
2014-07-04 19:24:06terry.reedycreate