Repository navigation
perf: lazily import public framework exports - #429
Merged
Merged
Conversation
Keep exceptions eager and load framework and Pyroscope exports on first access. Preserve __all__ and TYPE_CHECKING imports. Subprocess isolation regressions failed before the change and pass afterward. Python 3.14.7, local all-extras environment, seven fresh processes per command with -X importtime, median elapsed import time measured inside each process: - import lite_bootstrap: 680.95 -> 12.91 ms - from lite_bootstrap import FastAPIBootstrapper: 677.70 -> 273.73 ms - from lite_bootstrap import ConfigurationError: 730.97 -> 13.02 ms - from lite_bootstrap import PyroscopeConfig: 681.73 -> 90.14 ms Validation: 617 tests passed, 100% coverage; lint and ty passed. Standards and spec reviews found no issues.
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.
Importing
lite_bootstrappreviously loaded all five framework bootstrappers, including unrelated frameworks installed in the environment. Resolve framework and Pyroscope exports lazily through module__getattr__, cache resolved names, and retainTYPE_CHECKINGimports and__all__. Exceptions remain eager.__dir__keeps all public exports discoverable without loading frameworks.Closes #403.
Import timings
Python 3.14.7, local all-extras environment. Median elapsed import time across seven fresh processes per statement, with
-X importtimeenabled and timing measured inside each process:import lite_bootstrapfrom lite_bootstrap import FastAPIBootstrapperfrom lite_bootstrap import ConfigurationErrorfrom lite_bootstrap import PyroscopeConfigValidation
__dir__and now confirms all public exports appear without importing any framework or changingsys.modules.__all__resolves in a fresh process; repeated access preserves identity and unknown names raiseAttributeError.just test-ci: 618 passed, 100% coverage.just lint-ci: formatting, lint, and typechecking passed.