def unique(cls, iterable, key=None):
    """
    Yields unique items from *iterable* whilst preserving the original order.
    """

    if key is None:
      key = lambda x: x
    def generator():
      seen = set()
      seen_add = seen.add
      for item in iterable:
        key_val = key(item)
        if key_val not in seen:
          seen_add(key_val)
          yield item
    return cls(generator())
def unique ( cls , iterable , key = None ) : if key is None : key = lambda x : x def generator ( ) : seen = set ( ) seen_add = seen . add for item in iterable : key_val = key ( item ) if key_val not in seen : seen_add ( key_val ) yield item return cls ( generator ( ) )
Yields unique items from *iterable* whilst preserving the original order.