matplotlib / matplotlib/ipympl
Optimizations
- Dominant language
- Jupyter Notebook
- Stars
- 1.7k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
I feel like there could be some optimizations concerning the image update.
1. We should draw binary data directly on the canvas using:
```javascript
context.putImageData(binary_data);
```
instead of creating a Blob that is png encoded. That would also allow the back-end to not waste time encoding into png (if that is possible).
2. I feel like the "diff" computation should actually be slower than sending the full image, as it needs an extra computation of "which pixels actually needs a redraw?": https://github.com/matplotlib/matplotlib/blob/5fc44eea64a57ab1c6d236cf7c71906c9d40e6f6/lib/matplotlib/backends/backend_webagg_core.py#L190-L195.
Plus, we are still sending a full image. Maybe the png encoding does some compression if lots of pixels are transparent? If that is not the case, we are still sending the same amount of data.
Contributor guide
Research direction
Start with the referenced matplotlib/backends/backend_webagg_core.py image-update code and trace the corresponding canvas update entry point in ipympl. Compare the proposed binary-data path with the current PNG and diff paths, and define benchmarks and acceptance criteria before changing either side.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, python
- Domain
- backend, frontend, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100