Skip to content
Snippets Groups Projects
Commit 6246083a authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Add immutable records

parent c42a138c
No related branches found
No related tags found
No related merge requests found
......@@ -197,6 +197,19 @@ class Record(RecordWithoutPickling):
def __ne__(self, other):
return not self.__eq__(other)
class ImmutableRecordWithoutPickling(RecordWithoutPickling):
"Hashable record. Does not explicitly enforce immutability."
def __hash__(self):
return hash(
(type(self),) + tuple(getattr(self, field)
for field in self.__class__.fields))
class ImmutableRecord(Record, ImmutableRecordWithoutPickling):
pass
# }}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment