We could probably do it only once for each image widget (keeping the resulting HTMLImageElement in memory in a {"widget-model-id": HTMLImageElement} object, we can also automatically update this mapping if we see changes in the Image model).
That way animating an image would be more performant.
The slow part in ipycanvas is here when we use an Image widget: https://github.com/martinRenou/ipycanvas/blob/master/src/widget.ts#L786-L789 the slowness comes from this function https://github.com/martinRenou/ipycanvas/blob/658929381918dd89dc7f38a735fa7f9148a85f2b/src/widget.ts#L43-L62 which transforms the Image widget into an actual JavaScript
HTMLImageElement
objectWe could probably do it only once for each image widget (keeping the resulting
HTMLImageElement
in memory in a {"widget-model-id":HTMLImageElement
} object, we can also automatically update this mapping if we see changes in theImage
model).That way animating an image would be more performant.