is there any best practice for determining the equality of two arbitrary python objects? Let's say I'm writing a container for some kind of object, and I need to find out if the new objects correspond to the old ones stored in the container.
The problem is that I cannot use "is", as this will only check if the variables are associated with the same object (but we can have a deep copy of the object, which in my sense is equal to its original). I also cannot use "==", as some of these objects return evenly, like numpy arrays.
Is there a best practice for determining the equality of any objects? For instance,
repr(objectA)==repr(objectB)
enough?
Or commonly used:
numpy.all(objectA==objectB)
Which probably will not succeed if objectA == objectB evaluates to "[]"
Cheers, Robert
EDIT:
Well, in relation to the third comment, I will talk in detail about "What is your definition of" equal objects? "
In a strong sense, I have no definition of equality; rather, I will let the objects decide whether they are equal or not. The problem is, as I understand it, there is no well-agreed standard for eq or ==, respectively. A statement can return arrays or all kinds of things.
I mean, some operator allows you to call it SEQ (strong equality) between eq and "is". SEQ is superior to eq in the sense that it will always evaluate a single boolean value (for numpy arrays, which can mean that all elements are equal, for example) and determine whether objects are considered equal or not, But SEQ will give way to "is" in that sense that objects that are different in memory can be equal.