Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
hugovk merged 1 commit intomainfrom
version-file
Aug 6, 2024
Merged

Generate __version__ at build to avoid slow importlib.metadata import#195
hugovk merged 1 commit intomainfrom
version-file

Conversation

@hugovk
Copy link
Owner

@hugovk hugovk commented Aug 6, 2024

With Python 3.12.4:

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

Cuts out the 22ms importlib.metadata import.

main

image
hyperfine -w 8 "tinytext --version"
Benchmark 1: tinytext --version
  Time (mean ± σ):      49.2 ms ±   3.7 ms    [User: 38.2 ms, System: 9.5 ms]
  Range (min … max):    45.1 ms …  66.4 ms    62 runs

PR

image
hyperfine -w 8 "tinytext --version"
Benchmark 1: tinytext --version
  Time (mean ± σ):      26.4 ms ±   1.0 ms    [User: 19.8 ms, System: 5.5 ms]
  Range (min … max):    24.6 ms …  29.1 ms    105 runs

@hugovk hugovk added the changelog: Changed For changes in existing functionality label Aug 6, 2024
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