def _match_mismatch_counter(s1, p1, s2, p2):
 if (s1[p1] == s2[p2]):
  cmp_fn = operator.eq
  match = True
 else:
  cmp_fn = operator.ne
  match = False
 count = 1
 p1 += 1
 p2 += 1
 while ((p1 < len(s1)) and (p2 < len(s2)) and cmp_fn(s1[p1], s2[p2])):
  count += 1
  p1 += 1
  p2 += 1
 return (match, count)

def _match_mismatch_counter ( s1 , p1 , s2 , p2 ) : if ( s1 [ p1 ] == s2 [ p2 ] ) : cmp_fn = operator . eq match = True else : cmp_fn = operator . ne match = False count = 1 p1 += 1 p2 += 1 while ( ( p1 < len ( s1 ) ) and ( p2 < len ( s2 ) ) and cmp_fn ( s1 [ p1 ] , s2 [ p2 ] ) ) : count += 1 p1 += 1 p2 += 1 return ( match , count )
count consecutive matches/mismatches between strings s1 and s2 starting at p1 and p2 .