perf: skip savefig rendering in PYAUTO_FAST_PLOTS mode#255
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
PYAUTO_FAST_PLOTS=1, skipfig.savefig()insave_figure()andsubplot_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_PLOTSflag).API Changes
None — internal changes only. The
PYAUTO_FAST_PLOTSenv var now additionally skips file output (previously it only skippedtight_layout()).Test Plan
imaging/simulator.pydrops from 9.0s to 6.4s (subplot_tracer: 1.8s → 0.33s)Full API Changes (for automation & release notes)
Changed Behaviour
autoarray.plot.utils.save_figure()— whenPYAUTO_FAST_PLOTS=1, closes the figure immediately without callingfig.savefig()autoarray.plot.utils.subplot_save()— same behaviour as aboveautoarray.plot.utils._FAST_PLOTS— new module-level bool, cached at import time fromos.environ.get("PYAUTO_FAST_PLOTS") == "1"Migration
No migration needed — this is gated behind an opt-in environment variable.
🤖 Generated with Claude Code