import itertools


def peek(iterable, size=1):
    """
    >>> it = xbatch(2, range(10))
    >>> first_three, new_it = peek(it, 3)
    >>> first_three
    [range(0, 2), range(2, 4), range(4, 6)]
    >>> list(new_it)
    [range(0, 2), range(2, 4), range(4, 6), range(6, 8), range(8, 10)]
    >>> list(it)
    []
        
    >>> it = xbatch(2, range(10))
    >>> first_three, new_it = peek(it, 3)
    >>> first_three
    [range(0, 2), range(2, 4), range(4, 6)]
    >>> list(it)
    [range(6, 8), range(8, 10)]
    """
    objs = []
    for _ in range(size):
        try:
            obj = next(iterable)
        except StopIteration:
            break
        objs.append(obj)
    return objs, itertools.chain(objs, iterable)