FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Speedup x 1.85: Generate `__version__` at build to avoid slow `importlib.metadata` import by hugovk · Pull Request #200 · python-humanize/humanize · GitHub

Speedup x 1.85: Generate __version__ at build to avoid slow importlib.metadata import - #200

Merged
hugovk merged 2 commits into
python-humanize:mainfrom
hugovk:rm-importlib.metadata
Sep 9, 2024
Merged

Speedup x 1.85: Generate __version__ at build to avoid slow importlib.metadata import#200
hugovk merged 2 commits into
python-humanize:mainfrom
hugovk:rm-importlib.metadata

Conversation

hugovk commented Sep 9, 2024
edited
Loading

Copy link
Copy Markdown
Member

Like hugovk/tinytext#195.

With Python 3.13.0rc2:

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

main

PR

hyperfine

hyperfine --warmup 32 \
--prepare "git checkout rm-importlib.metadata" 'python3 -c "import humanize # PR"' \
--prepare "git checkout main"                  'python3 -c "import humanize # main"'
Benchmark 1: python3 -c "import humanize # PR"
  Time (mean ± σ):      23.5 ms ±   3.5 ms    [User: 18.0 ms, System: 4.3 ms]
  Range (min … max):    21.8 ms …  43.4 ms    75 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs.

Benchmark 2: python3 -c "import humanize # main"
  Time (mean ± σ):      43.4 ms ±   2.3 ms    [User: 34.5 ms, System: 7.6 ms]
  Range (min … max):    41.8 ms …  52.9 ms    52 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs.

Summary
  python3 -c "import humanize # PR" ran
    1.85 ± 0.29 times faster than python3 -c "import humanize # main"

Also move mypy from pre-commit to tox, so it runs when the version file has been generated.

hugovk added the changelog: Changed For changes in existing functionality label Sep 9, 2024
hugovk merged commit 74dcc60 into python-humanize:main Sep 9, 2024
hugovk deleted the rm-importlib.metadata branch September 9, 2024 18:27
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

Labels

changelog: Changed For changes in existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL