summaryrefslogtreecommitdiff
path: root/Cython/Utils.py
diff options
context:
space:
mode:
authorRobert Bradshaw <robertwb@gmail.com>2017-03-28 00:18:11 -0700
committerRobert Bradshaw <robertwb@gmail.com>2017-03-28 00:18:11 -0700
commit55af254cd711b12a35ed87ebea7de8c45a5e8af2 (patch)
treee6e6a4de4a3955e3985c5d9e09f69ee565ae2dbc /Cython/Utils.py
parentb390a172c93658964ebcb3bcc9f5ff8b07dc5518 (diff)
downloadcython-55af254cd711b12a35ed87ebea7de8c45a5e8af2.tar.gz
More determinism in fused types.
Diffstat (limited to 'Cython/Utils.py')
-rw-r--r--Cython/Utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Cython/Utils.py b/Cython/Utils.py
index 3479679b7..12fd0ed04 100644
--- a/Cython/Utils.py
+++ b/Cython/Utils.py
@@ -449,6 +449,22 @@ class LazyStr:
return left + self.callback()
+class OrderedSet(object):
+ def __init__(self, elements=()):
+ self._list = []
+ self._set = set()
+ self.update(elements)
+ def __iter__(self):
+ return iter(self._list)
+ def update(self, elements):
+ for e in elements:
+ self.add(e)
+ def add(self, e):
+ if e not in self._set:
+ self._list.append(e)
+ self._set.add(e)
+
+
# Class decorator that adds a metaclass and recreates the class with it.
# Copied from 'six'.
def add_metaclass(metaclass):