Skip to content

Conversation

@corv89
Copy link
Owner

@corv89 corv89 commented Dec 28, 2025

Summary

  • Lazy version loading: Replace eager importlib.metadata import with lazy get_version() function
  • Saves ~88ms on every CLI invocation by only loading version when actually needed (e.g., --version flag, remote deployment, JSON output)
  • Bump version to 0.9.4

Changes

  • Add get_version() function in config.py that caches the version
  • Create _LazyVersion class in cli.py for deferred --version lookup
  • Update all VERSION imports to use get_version() instead

Test plan

  • All tests pass (191 passed)
  • Verify shannot --version still works
  • Verify shannot status shows correct version

claude and others added 3 commits December 28, 2025 10:19
Replace eager importlib.metadata import with lazy get_version() function.
This avoids ~88ms overhead on every CLI invocation since importlib.metadata
is only loaded when the version string is actually needed (e.g., --version
flag, remote deployment, JSON output).

Changes:
- Add get_version() function in config.py that caches the version
- Create _LazyVersion class in cli.py for deferred --version lookup
- Update all VERSION imports to use get_version() instead
Replace eager importlib.metadata import with lazy get_version() function.
Saves ~88ms on every CLI invocation by only loading version when needed.
The _LazyVersion class approach breaks because argparse calls various
string methods (splitlines, __contains__) on the version. Using a custom
Action class that only loads the version when --version is invoked.
@corv89 corv89 self-assigned this Dec 28, 2025
@corv89 corv89 added the enhancement New feature or request label Dec 28, 2025
@corv89 corv89 merged commit c05b06d into main Dec 28, 2025
14 checks passed
@corv89 corv89 deleted the improve-startup-speed branch December 28, 2025 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants