Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate __version__ at build to avoid slow importlib.metadata import #218

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

hugovk
Copy link
Owner

@hugovk hugovk commented Aug 6, 2024

Like hugovk/tinytext#195.

With Python 3.12.4:

python -X importtime -c "import norwegianblue" 2> import.log && tuna import.log

Cuts out the 22ms importlib.metadata import.

main

image
hyperfine -w 8 "eol --version"
Benchmark 1: eol --version
  Time (mean ± σ):      55.1 ms ±   3.8 ms    [User: 43.3 ms, System: 10.4 ms]
  Range (min … max):    50.9 ms …  71.4 ms    53 runs

PR

image
hyperfine -w 8 "eol --version"
Benchmark 1: eol --version
  Time (mean ± σ):      38.2 ms ±   1.7 ms    [User: 29.6 ms, System: 7.3 ms]
  Range (min … max):    35.3 ms …  41.9 ms    73 runs

@hugovk hugovk added the changelog: Changed For changes in existing functionality label Aug 6, 2024
@hugovk hugovk merged commit 191b1d5 into main Aug 6, 2024
53 checks passed
@hugovk hugovk deleted the version-file branch August 6, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: Changed For changes in existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant