Skip to content

perf: skip savefig rendering in PYAUTO_FAST_PLOTS mode#255

Merged
Jammy2211 merged 1 commit intomainfrom
feature/fast-plots-skip-savefig
Apr 7, 2026
Merged

perf: skip savefig rendering in PYAUTO_FAST_PLOTS mode#255
Jammy2211 merged 1 commit intomainfrom
feature/fast-plots-skip-savefig

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

When PYAUTO_FAST_PLOTS=1, skip fig.savefig() in save_figure() and subplot_save(). All figure creation, data computation, and matplotlib drawing calls still execute — only the final rendering-to-file is bypassed. This saves ~2s per subplot figure by avoiding font discovery, text metrics, and PNG encoding.

Also caches the env var lookup at module import time (_FAST_PLOTS flag).

API Changes

None — internal changes only. The PYAUTO_FAST_PLOTS env var now additionally skips file output (previously it only skipped tight_layout()).

Test Plan

  • All 722 PyAutoArray tests pass
  • imaging/simulator.py drops from 9.0s to 6.4s (subplot_tracer: 1.8s → 0.33s)
  • Normal behavior unchanged without the env var
Full API Changes (for automation & release notes)

Changed Behaviour

  • autoarray.plot.utils.save_figure() — when PYAUTO_FAST_PLOTS=1, closes the figure immediately without calling fig.savefig()
  • autoarray.plot.utils.subplot_save() — same behaviour as above
  • autoarray.plot.utils._FAST_PLOTS — new module-level bool, cached at import time from os.environ.get("PYAUTO_FAST_PLOTS") == "1"

Migration

No migration needed — this is gated behind an opt-in environment variable.

🤖 Generated with Claude Code

When PYAUTO_FAST_PLOTS=1, skip fig.savefig() in save_figure() and
subplot_save(). The figure is still created, data computed, and all
matplotlib drawing calls (imshow, plot, etc.) still execute — only
the final rendering to file is bypassed. This avoids expensive font
discovery and text metrics computation during smoke tests.

Also cache the env var lookup at module import time for efficiency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 merged commit 434bac4 into main Apr 7, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant