matplotlib / matplotlib/ipympl

Optimizations

Open
#103 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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:
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).

  1. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.