Commits

Anonymous committed 2ff2871

[1.2.X] Fixed #12632 -- Improved performance of `SortedDict`. Thanks, Alex Gaynor.

Backport of r13742 from trunk.

Comments (0)

Files changed (1)

django/utils/datastructures.py

             self.keyOrder = data.keys()
         else:
             self.keyOrder = []
+            seen = set()
             for key, value in data:
-                if key not in self.keyOrder:
+                if key not in seen:
                     self.keyOrder.append(key)
+                    seen.add(key)
 
     def __deepcopy__(self, memo):
         return self.__class__([(key, deepcopy(value, memo))