Generator yielding each element only once.

        Note: May consume lots of memory depending on the given iterable.

def unique(iterable):
    """
        Generator yielding each element only once.

        Note: May consume lots of memory depending on the given iterable.
    """

    yielded = set()
    for i in iterable:
        if i in yielded:
            continue
        yield i
        yielded.add(i)