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

Avoid re-parsing the netloc when changing user/pass/host/port #1229

Merged
merged 3 commits into from
Oct 12, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Oct 12, 2024

Avoid re-parsing the netloc when changing user/pass/host/port

Do not call val.port, val.hostname, val.username, or val.password as they reparse the netloc again, and we already have them parsed and available in our internal methods.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 12, 2024
yarl/_url.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
@bdraco bdraco changed the title Avoid re-encoding hosts when changing user/pass/port (option 2) Avoid re-parsing the netloc when changing user/pass/host/port (option 2) Oct 12, 2024
@bdraco bdraco changed the title Avoid re-parsing the netloc when changing user/pass/host/port (option 2) Avoid re-parsing the netloc when changing user/pass/host/port Oct 12, 2024
Copy link

codspeed-hq bot commented Oct 12, 2024

CodSpeed Performance Report

Merging #1229 will improve performances by ×2

Comparing avoid_reencoding_2 (51611c9) with master (c02ba7f)

Summary

⚡ 4 improvements
✅ 36 untouched benchmarks

Benchmarks breakdown

Benchmark master avoid_reencoding_2 Change
test_url_with_host 1.5 ms 1.1 ms +36.13%
test_url_with_password 2.1 ms 1.1 ms +98.46%
test_url_with_port 1,952 µs 974.9 µs ×2
test_url_with_user 2.1 ms 1 ms ×2

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.77%. Comparing base (c02ba7f) to head (51611c9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1229   +/-   ##
=======================================
  Coverage   95.77%   95.77%           
=======================================
  Files          27       27           
  Lines        5084     5084           
  Branches      302      302           
=======================================
  Hits         4869     4869           
  Misses        189      189           
  Partials       26       26           
Flag Coverage Δ
CI-GHA 95.75% <100.00%> (ø)
MyPy 43.30% <100.00%> (ø)
OS-Linux 99.34% <100.00%> (ø)
OS-Windows 99.40% <100.00%> (ø)
OS-macOS 99.05% <100.00%> (ø)
Py-3.10.11 98.95% <100.00%> (ø)
Py-3.10.15 99.22% <100.00%> (ø)
Py-3.11.10 99.22% <100.00%> (ø)
Py-3.11.9 98.95% <100.00%> (ø)
Py-3.12.7 99.22% <100.00%> (ø)
Py-3.13.0 99.22% <100.00%> (ø)
Py-3.8.10 98.90% <100.00%> (ø)
Py-3.8.18 99.17% <100.00%> (ø)
Py-3.9.13 98.90% <100.00%> (ø)
Py-3.9.20 99.17% <100.00%> (ø)
Py-pypy7.3.11 99.22% <100.00%> (ø)
Py-pypy7.3.16 99.22% <100.00%> (ø)
Py-pypy7.3.17 99.25% <100.00%> (ø)
VM-macos-latest 99.05% <100.00%> (ø)
VM-ubuntu-latest 99.34% <100.00%> (ø)
VM-windows-latest 99.40% <100.00%> (ø)
pytest 99.34% <100.00%> (ø)

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 removed the bot:chronographer:provided There is a change note present in this PR label Oct 12, 2024
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 12, 2024
CHANGES/1229.misc.rst Outdated Show resolved Hide resolved
@bdraco bdraco marked this pull request as ready for review October 12, 2024 16:29
@bdraco bdraco enabled auto-merge (squash) October 12, 2024 16:29
@bdraco bdraco merged commit ef67a18 into master Oct 12, 2024
49 of 51 checks passed
@bdraco bdraco deleted the avoid_reencoding_2 branch October 12, 2024 16:30
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