Skip to content

Commit

Permalink
LazilyUnpickling{Dict,List}: add __repr__ (inducer#817)
Browse files Browse the repository at this point in the history
* LazilyUnpickling{Dict,List}: better repr

* add type to repr of PickledObject
  • Loading branch information
matthiasdiener authored Nov 14, 2024
1 parent 57f6654 commit 41b3288
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 @@ -348,6 +348,9 @@ def unpickle(self):
def __getstate__(self):
return {"objstring": self.objstring}

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


class _PickledObjectWithEqAndPersistentHashKeys(_PickledObject):
"""Like :class:`_PickledObject`, with two additional attributes:
Expand Down Expand Up @@ -406,6 +409,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 @@ -444,6 +450,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 41b3288

Please sign in to comment.