Skip to content

Commit

Permalink
LazilyUnpickling{Dict,List}: better repr
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Feb 12, 2024
1 parent 0b49c91 commit 8367398
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions loopy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ def unpickle(self):
def __getstate__(self):
return {"objstring": self.objstring}

def __repr__(self) -> str:
return repr(self.unpickle())


class _PickledObjectWithEqAndPersistentHashKeys(_PickledObject):
"""Like :class:`_PickledObject`, with two additional attributes:
Expand Down Expand Up @@ -464,6 +467,9 @@ def __getstate__(self):
key: _PickledObject(val)
for key, val in self._map.items()}}

def __repr__(self) -> str:
return type(self).__name__ + "(" + repr(self._map) + ")"

# }}}


Expand Down Expand Up @@ -502,6 +508,9 @@ def __add__(self, other):
def __mul__(self, other):
return self._list * other

def __repr__(self) -> str:
return type(self).__name__ + "(" + repr(self._list) + ")"


class LazilyUnpicklingListWithEqAndPersistentHashing(LazilyUnpicklingList):
"""A list which lazily unpickles its values, and supports equality comparison
Expand Down

0 comments on commit 8367398

Please sign in to comment.