Skip to content

add support for returning type of urllib.parse.ParseResult #13

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

abebus
Copy link

@abebus abebus commented May 23, 2025

Could resolve #2

Performance impact:
Yes, using namedtuple + acquiring scheme, netloc, path, params, query, fragment at creation time reduces performance slightly, but this implementation is still significantly faster than urllib.parse.

Benchmark results:

-------------------------------------------------------------------------------------- benchmark: 4 tests --------------------------------------------------------------------------------------
Name (time in ms)                  Min                 Max                Mean            StdDev              Median               IQR            Outliers     OPS            Rounds  Iterations
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_can_ada_parse            110.4494 (1.0)      111.9524 (1.0)      110.9987 (1.0)      0.5213 (1.0)      110.9586 (1.0)      0.7327 (1.46)          3;0  9.0091 (1.0)           9           1
test_can_ada_parse_compat     162.2488 (1.47)     164.3838 (1.47)     162.9126 (1.47)     0.7671 (1.47)     162.6683 (1.47)     0.5033 (1.0)           1;1  6.1383 (0.68)          6           1
test_ada_python_parse         208.3465 (1.89)     211.1058 (1.89)     209.3742 (1.89)     1.1097 (2.13)     209.4300 (1.89)     1.4970 (2.97)          1;0  4.7761 (0.53)          5           1
test_urllib_parse             470.5439 (4.26)     473.1951 (4.23)     472.0189 (4.25)     0.9800 (1.88)     472.0194 (4.25)     1.1805 (2.35)          2;0  2.1186 (0.24)          5           1
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

TODOs: ?

  • Add tests to ensure parse_compat matches urllib.parse.urlparse results
  • Consider adding ParseResultBytes and other result types
  • Explore cleaner approaches for the compatibility layer (without? introducing Cython)

@abebus
Copy link
Author

abebus commented Jun 10, 2025

@TkTech pinging :^)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support getting a urllib.parse.ParseResult namedtuple for drop-in compatibility.
1 participant