parameters: (message_descriptor, cls)
docstring: Helper for _AddMessageMethods().
docstring_summary: Helper for _AddMessageMethods().
docstring_tokens: Helper for _AddMessageMethods () .
function: def _AddByteSizeMethod(message_descriptor, cls):
    """Helper for _AddMessageMethods()."""
  
    def ByteSize(self):
      if not self._cached_byte_size_dirty:
        return self._cached_byte_size
  
      size = 0
      for field_descriptor, field_value in self.ListFields():
        size += field_descriptor._sizer(field_value)
  
      self._cached_byte_size = size
      self._cached_byte_size_dirty = False
      self._listener_for_children.dirty = False
      return size
  
    cls.ByteSize = ByteSize
function_tokens: def _AddByteSizeMethod ( message_descriptor , cls ) : def ByteSize ( self ) : if not self . _cached_byte_size_dirty : return self . _cached_byte_size size = 0 for field_descriptor , field_value in self . ListFields ( ) : size += field_descriptor . _sizer ( field_value ) self . _cached_byte_size = size self . _cached_byte_size_dirty = False self . _listener_for_children . dirty = False return size cls . ByteSize = ByteSize