def prefix_encode_all(ls):
 last = u('')
 for w in ls:
  i = first_diff(last, w)
  (yield (chr(i) + w[i:].encode('utf8')))
  last = w

def prefix_encode_all ( ls ) : last = u ( '' ) for w in ls : i = first_diff ( last , w ) ( yield ( chr ( i ) + w [ i : ] . encode ( 'utf8' ) ) ) last = w
compresses the given list of strings by storing each string as an integer representing the prefix it shares with its predecessor .