yields wondows of a given size

def window(iterable, size=2):
    ''' yields wondows of a given size '''
    iterable = iter(iterable)
    d = deque(islice(iterable, size-1), maxlen=size)
    for _ in map(d.append, iterable):
        yield tuple(d)