File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1+ import sys
12from collections import deque
2- from collections .abc import Mapping , Set
3+ from collections .abc import Mapping , Sequence , Set
34from contextlib import suppress
45
6+ __PY37 = sys .version_info >= (3 , 7 )
7+
58
69def transitive_get (key , d ):
710 """Get a value for a dict key in a transitive fashion.
@@ -90,9 +93,13 @@ def freeze(d):
9093 ((1, 2),)
9194 """
9295 if isinstance (d , Mapping ):
93- return tuple (map (freeze , sorted (d .items (), key = lambda x : hash (x [0 ]))))
96+ if __PY37 :
97+ items = d .items ()
98+ else :
99+ items = sorted (d .items (), key = lambda x : hash (x [0 ]))
100+ return tuple (map (freeze , items ))
94101 if isinstance (d , Set ):
95102 return tuple (map (freeze , sorted (d , key = hash )))
96- if isinstance (d , ( tuple , list ) ):
103+ if isinstance (d , Sequence ):
97104 return tuple (map (freeze , d ))
98105 return d
You can’t perform that action at this time.
0 commit comments