[kupfer] data: Use UniqueIterator



commit 51988ae57cfef00eca2e5a167344c05c1652eb2d
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Jan 4 15:31:53 2010 +0100

    data: Use UniqueIterator

 kupfer/data.py |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/kupfer/data.py b/kupfer/data.py
index 54bc8d4..62e987e 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -14,6 +14,7 @@ from . import objects
 from . import search, learn
 from . import config, pretty, scheduler, task
 from kupfer import commandexec
+from kupfer import datatools
 
 from kupfer import qfurl
 
@@ -108,13 +109,8 @@ class Searcher (object):
 					reverse=True)
 
 		def as_set_iter(seq):
-			"""yield items of @seq with set semantics; no duplicates"""
-			coll = set()
-			for obj in seq:
-				reprobj = obj.object
-				if reprobj not in coll:
-					yield obj
-					coll.add(reprobj)
+			key = operator.attrgetter("object")
+			return datatools.UniqueIterator(seq, key=key)
 
 		def valid_check(seq):
 			"""yield items of @seq that are valid"""



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]