Permalink
Browse files

Use sets instead of tuples in make_hashable

  • Loading branch information...
1 parent 202d63e commit 20872d8ba70521a4fda8aabb0b942fe568f6ee19 @scooby committed May 6, 2012
Showing with 6 additions and 4 deletions.
  1. +3 −2 example_dumper.py
  2. +3 −2 handle_mappings.py
View
@@ -79,9 +79,10 @@ def make_hashable(value):
if isinstance(value, list):
return tuple(map(make_hashable, value))
elif isinstance(value, set):
- return frozenset(map(make_hashable, value))
+ return frozenset(value)
elif isinstance(value, dict):
- return tuple(sorted((make_hashable(key), val) for key, val in value.items()))
+ return frozenset((make_hashable(key), make_hashable(val))
+ for key, val in value.items())
else:
return value
def new_items():
View
@@ -20,9 +20,10 @@ def make_hashable(value):
if isinstance(value, list):
return tuple(map(make_hashable, value))
elif isinstance(value, set):
- return frozenset(map(make_hashable, value))
+ return frozenset(value)
elif isinstance(value, dict):
- return tuple(sorted((make_hashable(key), val) for key, val in value.items()))
+ return frozenset((make_hashable(key), make_hashable(val))
+ for key, val in value.items())
else:
return value
def new_items():

0 comments on commit 20872d8

Please sign in to comment.