def unique_window(iterable, window, key=None):
 seen = collections.deque(maxlen=window)
 seen_add = seen.append
 if (key is None):
  for element in iterable:
   if (element not in seen):
    (yield element)
   seen_add(element)
 else:
  for element in iterable:
   k = key(element)
   if (k not in seen):
    (yield element)
   seen_add(k)

def unique_window ( iterable , window , key = None ) : seen = collections . deque ( maxlen = window ) seen_add = seen . append if ( key is None ) : for element in iterable : if ( element not in seen ) : ( yield element ) seen_add ( element ) else : for element in iterable : k = key ( element ) if ( k not in seen ) : ( yield element ) seen_add ( k )
unique_everseen -> iterator get unique elements .