[Python-ideas] Run length encoding
Tim Peters
tim.peters at gmail.com
Sun Jun 11 00:00:03 EDT 2017
In the other direction, e.g.,
def expand_rle(rle):
from itertools import repeat, chain
return list(chain.from_iterable(repeat(x, n) for x, n in rle))
Then
>>> expand_rle([('a', 5), ('bc', 3)])
['a', 'a', 'a', 'a', 'a', 'bc', 'bc', 'bc']
As to why zip is in the distribution, but not RLE, zip is a very
widely used, general purpose, compression standard. RLE is a
special-purpose thing.
More information about the Python-ideas
mailing list