Skip to content

Small speed up to normalizing the path#1137

Merged
bdraco merged 4 commits intomasterfrom
speed_up_normalize_path
Sep 9, 2024
Merged

Small speed up to normalizing the path#1137
bdraco merged 4 commits intomasterfrom
speed_up_normalize_path

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented Sep 9, 2024

What do these changes do?

  • Replace startswith with a single char check. startswith is a good choice for multiple chars, but its much slower for single chars
  • If there are no . in the path, don't normalize them as there is nothing to do. In testing 80% of paths did not have a . so we would needless normalize them

Are there changes in behavior for the user?

no

timeit
startswith: 0.005655332934111357
single char check: 0.0019642498809844255

before
before_normalize_path

after
after_normalize_path

Replace startswith with a single char check
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Sep 9, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.22%. Comparing base (07c4e03) to head (1c2f329).
Report is 278 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1137      +/-   ##
==========================================
+ Coverage   95.20%   95.22%   +0.02%     
==========================================
  Files          30       30              
  Lines        4709     4732      +23     
  Branches      417      419       +2     
==========================================
+ Hits         4483     4506      +23     
  Misses        200      200              
  Partials       26       26              
Flag Coverage Δ
CI-GHA 95.18% <100.00%> (+0.02%) ⬆️
MyPy 41.08% <100.00%> (+0.30%) ⬆️
OS-Linux 99.39% <100.00%> (+<0.01%) ⬆️
OS-Windows 99.49% <100.00%> (+<0.01%) ⬆️
OS-macOS 99.10% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 98.99% <100.00%> (+<0.01%) ⬆️
Py-3.10.14 99.23% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 99.23% <100.00%> (+<0.01%) ⬆️
Py-3.12.5 99.23% <100.00%> (+<0.01%) ⬆️
Py-3.13.0-rc.1 99.23% <100.00%> (+<0.01%) ⬆️
Py-3.8.10 98.94% <100.00%> (+<0.01%) ⬆️
Py-3.8.18 99.18% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 98.94% <100.00%> (+<0.01%) ⬆️
Py-3.9.19 99.18% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.11 99.23% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.16 99.23% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.17 99.26% <100.00%> (+<0.01%) ⬆️
VM-macos-latest 99.10% <100.00%> (+<0.01%) ⬆️
VM-ubuntu-latest 99.39% <100.00%> (+<0.01%) ⬆️
VM-windows-latest 99.49% <100.00%> (+<0.01%) ⬆️
pytest 99.39% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco bdraco marked this pull request as ready for review September 9, 2024 18:28
@bdraco bdraco merged commit 1e969ab into master Sep 9, 2024
@bdraco bdraco deleted the speed_up_normalize_path branch September 9, 2024 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant