The existing code unnecessarily unpacks the args and then repacks them. Also, it uses a pure Python generator-expression when we already have a C speed itertool:
@staticmethod
def decode(iterable):
return chain.from_iterable(repeat(k, n) for k, n in iterable)
New code:
@staticmethod
def decode(iterable):
return chain.from_iterable(starmap(repeat, compressed))
The edit shifts to a more functional style and eliminates the uninformative variable names.
The existing code unnecessarily unpacks the args and then repacks them. Also, it uses a pure Python generator-expression when we already have a C speed itertool:
New code:
The edit shifts to a more functional style and eliminates the uninformative variable names.