code: def _cmpFormatRanges(a, b):
      
      if a.format == b.format and \
         a.start == b.start and \
         a.length == b.length:
          return 0
      else:
          return cmp(id(a), id(b))
docs: PyQt does not define proper comparison for QTextLayout.FormatRange
      Define it to check correctly, if formats has changed.
      It is important for the performance