inducer / loopy

A code generator for array-based code on CPUs and GPUs
http://mathema.tician.de/software/loopy
MIT License
565 stars 71 forks source link

LazilyUnpickling{Dict,List}: add __repr__ #817

Open matthiasdiener opened 7 months ago

matthiasdiener commented 7 months ago
from loopy.tools import LazilyUnpicklingList, LazilyUnpicklingDict, _PickledObject
l = LazilyUnpicklingList([1, 2, 3, 4])
print(l)
d = LazilyUnpicklingDict({'a':1, 'b':2})
print(d)
p = _PickledObject(7)
print(p)

before:

<loopy.tools.LazilyUnpicklingList object at 0x101810810>
<loopy.tools.LazilyUnpicklingDict object at 0x104b2ccd0>
<loopy.tools._PickledObject object at 0x10103a450>

after:

LazilyUnpicklingList([1, 2, 3, 4])
LazilyUnpicklingDict({'a': 1, 'b': 2})
_PickledObject(7)

(If you want, I could add __str__ methods that don't include the class names.)

matthiasdiener commented 7 months ago

This is ready for review.