PERF: Lazily load exports infrastructure - #2455
Merged
Richard Lundeen (rlundeen2) merged 2 commits intoAug 22, 2026
Merged
Conversation
Defer model re-exports until first access and add a repository-wide lazy package contract test with a ratcheting eager-package exception list. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d2bd1e1d-bef9-454a-b04a-be5fde48fcab
This was referenced Aug 21, 2026
Exercise model package dir hooks and export resolution in the coverage process so diff coverage includes the PEP 562 contract. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d2bd1e1d-bef9-454a-b04a-be5fde48fcab
Roman Lutz (romanlutz)
approved these changes
Aug 22, 2026
Roman Lutz (romanlutz)
left a comment
Contributor
There was a problem hiding this comment.
Very interesting!
Richard Lundeen (rlundeen2)
deleted the
rlundeen2-speed-pyrit-cold-start
branch
August 22, 2026 03:22
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.
Description
This is the first PR in a two-PR change stack. Follow-up: #2456.
Add a shared PEP 562 lazy-import helper that resolves and caches package exports on first access while exposing unresolved names through
dir().Migrate all public
pyrit.modelspackage exports to this contract._LAZY_EXPORTSis the runtime source of truth,__all__derives from it, andTYPE_CHECKINGimports preserve editor and static-analysis support. Existing named imports and object identity remain compatible.Add focused helper tests and a repository-wide package contract test. The contract test discovers every package initializer, validates migrated packages, spot-checks model imports, and maintains an exact exception ratchet for packages that remain eager.
Tests and Documentation
python -m pytest -q tests\unit\common tests\unit\models— 1,426 passedSKIP=ty-check python -m pre_commit run --all-files— passedty-checkhook was stopped after it stalled in the local environment.