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

Improve performance of _encode_host #1176

Merged
merged 4 commits into from
Oct 5, 2024
Merged

Improve performance of _encode_host #1176

merged 4 commits into from
Oct 5, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Oct 5, 2024

What do these changes do?

Improve performance of _encode_host

  • If we are not running the potential ip address path, avoid checking for IPv6 zone
  • If the parsed address is not IPv6, avoid trying to join the IPv6 zone back to it

This one is very small, I only noticed it because I was looking over _encode_host
and wondering why we were looking for an IP zone outside of the ip address block

Are there changes in behavior for the user?

no

before
__new__before

after
__new__after

yarl/_url.py Outdated Show resolved Hide resolved
@bdraco bdraco changed the title Improve performance of _encode_host Fix handling of IPv4 address with zone Oct 5, 2024
@bdraco
Copy link
Member Author

bdraco commented Oct 5, 2024

While this is wrong, we probably shouldn't change it for IPv4.... since we aren't supposed to support it for IPv6 according to https://url.spec.whatwg.org/

Support for <zone_id> is intentionally omitted.

There likely isn't a use case for a zone in an IPv4 address but there is for IPv6 (maybe not in practice though).

@bdraco bdraco changed the title Fix handling of IPv4 address with zone Improve performance of _encode_host Oct 5, 2024
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 5, 2024
Copy link

codecov bot commented Oct 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.57%. Comparing base (cf08033) to head (1ba14bf).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1176      +/-   ##
==========================================
- Coverage   95.57%   95.57%   -0.01%     
==========================================
  Files          30       30              
  Lines        4926     4924       -2     
  Branches      448      447       -1     
==========================================
- Hits         4708     4706       -2     
  Misses        192      192              
  Partials       26       26              
Flag Coverage Δ
CI-GHA 95.53% <100.00%> (-0.01%) ⬇️
MyPy 42.15% <100.00%> (-0.03%) ⬇️
OS-Linux 99.38% <100.00%> (-0.01%) ⬇️
OS-Windows 99.48% <100.00%> (-0.01%) ⬇️
OS-macOS 99.10% <100.00%> (-0.01%) ⬇️
Py-3.10.11 99.00% <100.00%> (-0.01%) ⬇️
Py-3.10.15 99.23% <100.00%> (-0.01%) ⬇️
Py-3.11.10 99.23% <100.00%> (-0.01%) ⬇️
Py-3.11.9 99.00% <100.00%> (-0.01%) ⬇️
Py-3.12.6 99.23% <100.00%> (-0.01%) ⬇️
Py-3.13.0-rc.3 99.23% <100.00%> (-0.01%) ⬇️
Py-3.8.10 98.95% <100.00%> (-0.01%) ⬇️
Py-3.8.18 99.18% <100.00%> (-0.01%) ⬇️
Py-3.9.13 98.95% <100.00%> (-0.01%) ⬇️
Py-3.9.20 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.38% <100.00%> (-0.01%) ⬇️
VM-windows-latest 99.48% <100.00%> (-0.01%) ⬇️
pytest 99.38% <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 October 5, 2024 15:17
@bdraco bdraco merged commit d2892da into master Oct 5, 2024
47 of 49 checks passed
@bdraco bdraco deleted the _encode_host branch October 5, 2024 15:17
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