Skip to content
New issue

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

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

Already on GitHub? # to your account

Break out functions that do not need decorated methods #1345

Merged
merged 2 commits into from
Oct 20, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Oct 20, 2024

classmethods and staticmethods are slower than normal methods, and these methods never need anything on the URL objects like _normalize_path_segments

classmethods are slower than normal methods, and these methods
never need anything on the URL objects like _normalize_path_segments
@bdraco bdraco added the bot:chronographer:skip This PR does not need to include a change note label Oct 20, 2024
@bdraco bdraco changed the title Break out functions that do not need classmethod Break out functions that do not need decorated methods Oct 20, 2024
Copy link

codspeed-hq bot commented Oct 20, 2024

CodSpeed Performance Report

Merging #1345 will improve performances by 20.84%

Comparing class_method_slower (becd09a) with master (ba390c7)

Summary

⚡ 22 improvements
✅ 61 untouched benchmarks

Benchmarks breakdown

Benchmark master class_method_slower Change
test_raw_host_empty_cache 291.1 µs 240.9 µs +20.84%
test_url_build_access_fragment 723 µs 634.6 µs +13.93%
test_url_build_access_raw_host 855.1 µs 730.9 µs +16.99%
test_url_build_access_raw_path 769.9 µs 686.5 µs +12.15%
test_url_build_access_username_password 977.3 µs 851.6 µs +14.75%
test_url_build_with_different_hosts 1.9 ms 1.8 ms +10.15%
test_url_build_with_host 592.9 µs 512.4 µs +15.72%
test_url_build_with_host_and_port 811.3 µs 730.3 µs +11.1%
test_url_build_with_host_path_and_port 720.8 µs 643.4 µs +12.04%
test_url_make_access_fragment 801 µs 722.8 µs +10.83%
test_url_make_access_raw_host 710.2 µs 630 µs +12.73%
test_url_make_access_raw_path 854.3 µs 767.1 µs +11.37%
test_url_make_access_username_password 983.9 µs 864.6 µs +13.79%
test_url_make_empty_password 876.4 µs 757.2 µs +15.75%
test_url_make_empty_username 880.5 µs 763 µs +15.4%
test_url_make_with_host_and_path 676.3 µs 596.3 µs +13.42%
test_url_make_with_host_path_and_port 905.2 µs 777.3 µs +16.45%
test_url_make_with_ipv4_address_and_path 795.1 µs 710.5 µs +11.92%
test_url_make_with_ipv4_address_path_and_port 938.4 µs 814.2 µs +15.26%
test_url_make_with_ipv6_address_and_path 932.4 µs 805.2 µs +15.79%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Copy link

codecov bot commented Oct 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.09%. Comparing base (2bb826b) to head (becd09a).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1345      +/-   ##
==========================================
+ Coverage   96.02%   96.09%   +0.07%     
==========================================
  Files          27       27              
  Lines        5479     5482       +3     
  Branches      338      336       -2     
==========================================
+ Hits         5261     5268       +7     
+ Misses        192      188       -4     
  Partials       26       26              
Flag Coverage Δ
CI-GHA 96.09% <100.00%> (+0.07%) ⬆️
MyPy 44.60% <97.01%> (+0.14%) ⬆️
OS-Linux 99.22% <100.00%> (+<0.01%) ⬆️
OS-Windows 99.26% <100.00%> (+<0.01%) ⬆️
OS-macOS 98.95% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 98.80% <100.00%> (+<0.01%) ⬆️
Py-3.10.15 99.04% <100.00%> (+<0.01%) ⬆️
Py-3.11.10 99.17% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 98.93% <100.00%> (+<0.01%) ⬆️
Py-3.12.7 99.17% <100.00%> (+<0.01%) ⬆️
Py-3.13.0 99.17% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 98.75% <100.00%> (+<0.01%) ⬆️
Py-3.9.20 99.00% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.16 99.03% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.17 99.05% <100.00%> (+<0.01%) ⬆️
VM-macos-latest 98.95% <100.00%> (+<0.01%) ⬆️
VM-ubuntu-latest 99.22% <100.00%> (+<0.01%) ⬆️
VM-windows-latest 99.26% <100.00%> (+<0.01%) ⬆️
pytest 99.22% <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 closed this Oct 20, 2024
@bdraco bdraco reopened this Oct 20, 2024
@bdraco
Copy link
Member Author

bdraco commented Oct 20, 2024

I'm not sure the static method is actually slower

If not might be nicer to make them static instead as it's less change

@bdraco
Copy link
Member Author

bdraco commented Oct 20, 2024

For this case, this change makes the most sense since we have some of them calling each other

@bdraco bdraco marked this pull request as ready for review October 20, 2024 22:56
@bdraco
Copy link
Member Author

bdraco commented Oct 20, 2024

staticmethod is a tiny bit slower

@bdraco bdraco removed the bot:chronographer:skip This PR does not need to include a change note label Oct 20, 2024
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 20, 2024
@bdraco bdraco merged commit 4e06f7d into master Oct 20, 2024
43 of 46 checks passed
@bdraco bdraco deleted the class_method_slower branch October 20, 2024 23:12
# for free to join this conversation on GitHub. Already have an account? # 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