Enh: Defer expensive loading of dask.array#2276
Merged
andrewgsavage merged 5 commits intohgrecco:masterfrom Mar 2, 2026
Merged
Enh: Defer expensive loading of dask.array#2276andrewgsavage merged 5 commits intohgrecco:masterfrom
andrewgsavage merged 5 commits intohgrecco:masterfrom
Conversation
6 tasks
Collaborator
|
looks good, do add a changes note |
Collaborator
|
doctest fail looks unrelated |
Contributor
Author
Thanks! Done! I wasn't sure if I should reference the issue or the PR in the parens. I went with the issue number? |
Contributor
Author
|
Oh interesting, it looks like
|
Contributor
Author
|
The lint fail appears to be due to pixi version? |
3 tasks
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.
pre-commit run --all-filesorpixi run lint --all-fileswith no errorsThis is a performance enhancement, aimed at the import time of pint.
As noted int he issue, dask.array is a expensive import, so in this PR I attempt to address the issue by deferring it's loading from
import pint(dask/dask.base in contrast are pretty light, so I leave them alone to keep this simple.)With this PR (all are second runs)
python -X importtime -c 'import pint'bottom line:import time: 649 | 176212 | pintpython -X importtime -c 'import pint' 2>&1 | grep dask.arraypython -X importtime -c 'import pint' 2>&1 | grep daskWith main:
python -X importtime -c 'import pint'bottom line:import time: 630 | 465967 | pintpython -X importtime -c 'import pint' 2>&1 | grep dask.arrayimport time: 244 | 278716 | dask.arraypython -X importtime -c 'import pint' 2>&1 | grep dask.baseWith this PR in pint we can tuck some
import dask.array as daimports in napari into functions and save ~250 ms on our startup time.Edit: this has a nice side-effect of also resulting in
import pintnot importing pandas.