parameters: (message_descriptor, cls)
docstring: Helper for _AddMessageMethods().
docstring_summary: Helper for _AddMessageMethods().
docstring_tokens: Helper for _AddMessageMethods () .
function: def _AddEqualsMethod(message_descriptor, cls):
    """Helper for _AddMessageMethods()."""
    def __eq__(self, other):
      if (not isinstance(other, message_mod.Message) or
          other.DESCRIPTOR != self.DESCRIPTOR):
        return False
  
      if self is other:
        return True
  
      if self.DESCRIPTOR.full_name == _AnyFullTypeName:
        any_a = _InternalUnpackAny(self)
        any_b = _InternalUnpackAny(other)
        if any_a and any_b:
          return any_a == any_b
  
      if not self.ListFields() == other.ListFields():
        return False
  
      # Sort unknown fields because their order shouldn't affect equality test.
      unknown_fields = list(self._unknown_fields)
      unknown_fields.sort()
      other_unknown_fields = list(other._unknown_fields)
      other_unknown_fields.sort()
  
      return unknown_fields == other_unknown_fields
  
    cls.__eq__ = __eq__
function_tokens: def _AddEqualsMethod ( message_descriptor , cls ) : def __eq__ ( self , other ) : if ( not isinstance ( other , message_mod . Message ) or other . DESCRIPTOR != self . DESCRIPTOR ) : return False if self is other : return True if self . DESCRIPTOR . full_name == _AnyFullTypeName : any_a = _InternalUnpackAny ( self ) any_b = _InternalUnpackAny ( other ) if any_a and any_b : return any_a == any_b if not self . ListFields ( ) == other . ListFields ( ) : return False # Sort unknown fields because their order shouldn't affect equality test. unknown_fields = list ( self . _unknown_fields ) unknown_fields . sort ( ) other_unknown_fields = list ( other . _unknown_fields ) other_unknown_fields . sort ( ) return unknown_fields == other_unknown_fields cls . __eq__ = __eq__