summaryrefslogtreecommitdiff
path: root/lib/spack/llnl/util/lang.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/llnl/util/lang.py')
-rw-r--r--lib/spack/llnl/util/lang.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index df32012e2d..253334c416 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -374,6 +374,22 @@ def DictWrapper(dictionary):
return wrapper()
+def dedupe(sequence):
+ """Yields a stable de-duplication of an hashable sequence
+
+ Args:
+ sequence: hashable sequence to be de-duplicated
+
+ Returns:
+ stable de-duplication of the sequence
+ """
+ seen = set()
+ for x in sequence:
+ if x not in seen:
+ yield x
+ seen.add(x)
+
+
class RequiredAttributeError(ValueError):
def __init__(self, message):