r"""
    equivalent to iter_window(iterable, 2, 1, wrap)

    Args:
        iterable (iter): an iterable sequence
        wrap (bool): if True, returns with wraparound

    Returns:
        iter: returns edges in a sequence

    CommandLine:
        python -m utool.util_iter --test-itertwo

    Example0:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_iter import *  # NOQA
        >>> iterable = [1, 2, 3, 4]
        >>> wrap = False
        >>> edges = list(itertwo(iterable, wrap))
        >>> result = ('edges = %r' % (edges,))
        >>> print(result)
        edges = [(1, 2), (2, 3), (3, 4)]

    Example1:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_iter import *  # NOQA
        >>> iterable = [1, 2, 3, 4]
        >>> wrap = True
        >>> edges = list(itertwo(iterable, wrap))
        >>> result = ('edges = %r' % (edges,))
        >>> print(result)
        edges = [(1, 2), (2, 3), (3, 4), (4, 1)]

    Example2:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_iter import *  # NOQA
        >>> import utool as ut
        >>> iterable = iter([1, 2, 3, 4])
        >>> wrap = False
        >>> edge_iter = itertwo(iterable, wrap)
        >>> edges = list(edge_iter)
        >>> result = ('edges = %r' % (edges,))
        >>> ut.assert_eq(len(list(iterable)), 0, 'iterable should have been used up')
        >>> print(result)
        edges = [(1, 2), (2, 3), (3, 4)]

    Timeit:
        >>> import vtool as vt
        >>> import utool as ut
        >>> # itertwo is slower than zip slicing on python lists
        >>> # but faster on numpy arrays
        >>> setup = ut.codeblock(
            '''
            import random
            import utool as ut
            import numpy as np
            rng = random.Random(0)
            iterable = [rng.randint(0, 2000) for _ in range(100000)]
            iterable2 = np.array(iterable)
            ''')
        >>> stmt_list = ut.codeblock(
            '''
            list(zip(iterable, iterable[1:]))
            list(ut.itertwo(iterable))
            list(ut.iter_window(iterable, 2))
            list(zip(iterable2, iterable2[1:]))
            list(zip(iterable2.tolist(), iterable2.tolist()[1:]))
            list(ut.itertwo(iterable2))
            list(ut.itertwo(iterable2.tolist()))
            ''').split('\n')
        >>> passed, times, outputs = ut.timeit_compare(stmt_list, setup, iterations=10)

def itertwo(iterable, wrap=False):
    r"""
    equivalent to iter_window(iterable, 2, 1, wrap)

    Args:
        iterable (iter): an iterable sequence
        wrap (bool): if True, returns with wraparound

    Returns:
        iter: returns edges in a sequence

    CommandLine:
        python -m utool.util_iter --test-itertwo

    Example0:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_iter import *  # NOQA
        >>> iterable = [1, 2, 3, 4]
        >>> wrap = False
        >>> edges = list(itertwo(iterable, wrap))
        >>> result = ('edges = %r' % (edges,))
        >>> print(result)
        edges = [(1, 2), (2, 3), (3, 4)]

    Example1:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_iter import *  # NOQA
        >>> iterable = [1, 2, 3, 4]
        >>> wrap = True
        >>> edges = list(itertwo(iterable, wrap))
        >>> result = ('edges = %r' % (edges,))
        >>> print(result)
        edges = [(1, 2), (2, 3), (3, 4), (4, 1)]

    Example2:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_iter import *  # NOQA
        >>> import utool as ut
        >>> iterable = iter([1, 2, 3, 4])
        >>> wrap = False
        >>> edge_iter = itertwo(iterable, wrap)
        >>> edges = list(edge_iter)
        >>> result = ('edges = %r' % (edges,))
        >>> ut.assert_eq(len(list(iterable)), 0, 'iterable should have been used up')
        >>> print(result)
        edges = [(1, 2), (2, 3), (3, 4)]

    Timeit:
        >>> import vtool as vt
        >>> import utool as ut
        >>> # itertwo is slower than zip slicing on python lists
        >>> # but faster on numpy arrays
        >>> setup = ut.codeblock(
            '''
            import random
            import utool as ut
            import numpy as np
            rng = random.Random(0)
            iterable = [rng.randint(0, 2000) for _ in range(100000)]
            iterable2 = np.array(iterable)
            ''')
        >>> stmt_list = ut.codeblock(
            '''
            list(zip(iterable, iterable[1:]))
            list(ut.itertwo(iterable))
            list(ut.iter_window(iterable, 2))
            list(zip(iterable2, iterable2[1:]))
            list(zip(iterable2.tolist(), iterable2.tolist()[1:]))
            list(ut.itertwo(iterable2))
            list(ut.itertwo(iterable2.tolist()))
            ''').split('\n')
        >>> passed, times, outputs = ut.timeit_compare(stmt_list, setup, iterations=10)

    """
    # it.tee may be slow, but works on all iterables
    iter1, iter2 = it.tee(iterable, 2)
    if wrap:
        iter2 = it.cycle(iter2)
    try:
        six.next(iter2)
    except StopIteration:
        return iter(())
    else:
        return zip(iter1, iter2)