perf: defer heavy imports in giant/dwarf CLIs until commands run #91

Merged
lars merged 2 commits from cli-lazy-imports into master 2026-08-28 14:21:10 +02:00
Owner

torch/pandas/pyarrow/polars/uproot/awkward/particle were all imported
at module scope in giant/cli.py and giant/tools/dwarf.py, so even
--help paid ~1.6-1.9s of import cost. Move those imports into the
command bodies that actually need them (following the deferred-import
pattern already used for analysis/render/plots/sklearn/wandb), cutting
giant --help to ~0.3s and dwarf --help to ~0.2s with no change to
any command's actual behavior.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

torch/pandas/pyarrow/polars/uproot/awkward/particle were all imported at module scope in giant/cli.py and giant/tools/dwarf.py, so even `--help` paid ~1.6-1.9s of import cost. Move those imports into the command bodies that actually need them (following the deferred-import pattern already used for analysis/render/plots/sklearn/wandb), cutting `giant --help` to ~0.3s and `dwarf --help` to ~0.2s with no change to any command's actual behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
lars added 1 commit 2026-08-28 14:11:01 +02:00
perf: defer heavy imports in giant/dwarf CLIs until commands run
CI / Sync project version with tag (push) Has been skipped
CI / Type check (ty) (push) Successful in 19s
CI / Format (ruff format) (push) Successful in 21s
CI / Lint (ruff check) (push) Successful in 25s
CI / Sync project version with tag (pull_request) Has been skipped
CI / Type check (ty) (pull_request) Successful in 4m5s
CI / Format (ruff format) (pull_request) Successful in 4m5s
CI / Lint (ruff check) (pull_request) Successful in 4m15s
CI / Tests (pull_request) Successful in 5m15s
CI / Bump version, tag, and update changelog on merge to master (pull_request) Has been skipped
CI / Tests (push) Successful in 9m55s
CI / Bump version, tag, and update changelog on merge to master (push) Has been skipped
516a8a9ee1
torch/pandas/pyarrow/polars/uproot/awkward/particle were all imported
at module scope in giant/cli.py and giant/tools/dwarf.py, so even
`--help` paid ~1.6-1.9s of import cost. Move those imports into the
command bodies that actually need them (following the deferred-import
pattern already used for analysis/render/plots/sklearn/wandb), cutting
`giant --help` to ~0.3s and `dwarf --help` to ~0.2s with no change to
any command's actual behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
lars added 1 commit 2026-08-28 14:11:19 +02:00
Merge branch 'master' into cli-lazy-imports
CI / Format (ruff format) (pull_request) Successful in 29s
CI / Lint (ruff check) (pull_request) Successful in 34s
CI / Sync project version with tag (pull_request) Has been skipped
CI / Type check (ty) (pull_request) Successful in 32s
CI / Tests (pull_request) Successful in 2m51s
CI / Bump version, tag, and update changelog on merge to master (pull_request) Has been skipped
CI / Publish package to Gitea package registry (pull_request) Has been skipped
8d1c29efdd
lars merged commit 70d018982b into master 2026-08-28 14:21:10 +02:00
lars deleted branch cli-lazy-imports 2026-08-28 14:21:11 +02:00
Sign in to join this conversation.