Patch Changes
-
Override repr to avoid expensive trait serialization #906 (#906)
Previously,
AnyWidgetinheritedipywidgets.Widget.__repr__which serialized all trait values. This is costly because the repr might not even be shown to users, yet it forces a full serialization of potentially large data.AnyWidgetnow overrides__repr__to useobject.__repr__(self), which produces a simple<module.ClassName object at 0x...>format.To restore the previous behavior showing all trait values, users can define:
class MyWidget(anywidget.AnyWidget): def __repr__(self): return traitlets.HasTraits.__repr__(self)