When implementing the __eq__ function I was wondering if testing for identity using the is keyword should be part of the test? Testing for equality for 2 different variables can immediately evaluate to True by the is function when variables point to the same object instance. In case variables point to different instances further testing is needed of course. Say we have S = U then obviously we want S == U to return True and testing for identity will speed this up.
def __eq__(self, other):
if self is other:
return True
else:
pass # do another user defined test for equality