from itertools import tee, chain


def with_previous_s6(iterable):
    """Provide each sequence item with item before it
    
    Comments:
        The 'tee' function creates two independent iterators
        from the passed iterator

        The 'chain' function creates a new iterator combining the 
        passed sequences, in a memory efficient way - it only caches one
        item at a time

        The 'zip' function returns a list of tuples, where the first item of each
        tuple is the first item of the first iterator, and the second item of the 
        tuple is the first item of the second iterator.

        The final result is like this:
            [(item1, prev1), (item2, item1), ...]
    """

    i1, i2 = tee(iterable)
    return zip(i1, chain([None], i2))