def verify(values): enc = Encoder(values) sequence, pairs = enc.encode() dec = Decoder(sequence, pairs) decoded = dec.decode() assert decoded == values
def demo(values): enc = Encoder(values) sequence, pairs = enc.encode() orig_size = sum(encoded_size(v) for v in values) seq_size = sum(encoded_size(v) for v in sequence) pairs_size = sum(encoded_size(v) for v in pairs) pairs_size += sum(encoded_size(pair[0]) + encoded_size(pair[1]) for pair in pairs.itervalues()) print 'original size: ', orig_size print print 'sequence size: ', seq_size print ' pairs size: ', pairs_size print ' total size: ', seq_size + pairs_size