It's not even guaranteed that two objects that compare equal with ==
pickle the same:
>>> x = (1,)
>>> y = (x, x)
>>> z = ((1,), (1,))
>>> y == z
True
>>> pickle.dumps(y) == pickle.dumps(z)
False
>>> {-1, -2} == {-2, -1}
True
>>> pickle.dumps({-1, -2}) == pickle.dumps({-2, -1})
False
Serializing objects to compare their serialized forms is not a workable general-purpose equality comparison. If you want to define your own concept of equality, writing your own equality comparison function is probably your best bet.