import array


def decode(lst, typecode):
    """decode to array

    >>> decode( [(4, 10), (4, 20)], typecode="i" )
    array('i', [10, 10, 10, 10, 20, 20, 20, 20])

    >>> decode( [(5, 'a'), (6, 'h'), (7, 'm'), (1, 'u'), (7, 'i'), (6, 'a')], typecode="c" )
    array('c', 'aaaaahhhhhhmmmmmmmuiiiiiiiaaaaaa')

    """
    a = array.array(typecode)
    for n, c in lst:
        a.extend(array.array(typecode, (c,) * n))
    return a