Repository navigation
[python] helpers: import matplotlib only in the plotting functions - #193
Merged
Merged
Conversation
yanissrairi
force-pushed
the
perf/lazy-matplotlib
branch
2 times, most recently
from
October 5, 2026 12:11
7098209 to
f45d70b
Compare
import pyforefire was loading matplotlib even when nothing is plotted.
yanissrairi
force-pushed
the
perf/lazy-matplotlib
branch
from
October 5, 2026 12:14
f45d70b to
0765090
Compare
Contributor
|
thanks @yanissrairi |
Collaborator
|
@filippi not a problem on my side. I don't have PRs open to |
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.
pyforefire/__init__.pystar-importshelpers, which imported matplotlib at module level, so everyimport pyforefireloaded it even when nothing is plotted. The imports now live in the two functions that use them,printToPatheandplot_simulation.Fresh interpreter, median of 30 runs (Python 3.14, matplotlib 3.11):
import pyforefire: 0.191 s -> 0.039 sThis matters when running many short simulations in separate processes.
The helper functions return the same outputs as before, and
percolation.pyandidealizedwind.pyintests/pythonproduce identical files with a fixed seed. One side effect:plt,cm,mpath,mpatchesandListedColormapare no longer re-exported bypyforefirethrough the star import. Nothing in this repository relies on that.