◐ Shell
clean mode source ↗

Message 222442 - Python tracker

I see.
But I don't think it is a sensible default, as the source code states.

The Python doc (v2 and v3) is quite consistent in stating that `==` compares the values of two objects, while `is` compares object identity.

Having a default implementation on the object type that implements `==` by comparing object identity is not consistent with that.

-> Can someone please elaborate what the reason for that is?

-> Where is the discrepancy between the documentation of == and its default implementation on object documented?

To me, a sensible default implementation for == on object would be (in Python):

  if v is w:
    return True;
  elif type(v) != type(w):
    return False
  else:
    raise ValueError("Equality cannot be determined in default implementation")

Andy