#35467: Prefer urlsplit() over urlparse() -------------------------------------+------------------------------------- Reporter: Adam Johnson | Owner: nobody Type: | Status: new Cleanup/optimization | Component: Utilities | Version: dev Severity: Normal | Resolution: Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Description changed by Adam Johnson:
Old description: > Many places in Django use > [`urlparse()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse), > which supports the rarely-used “path parameter” syntax (not to be > confused with query parameters). The `urlsplit()` function is similar but > does not parse such path parameters, which makes it a bit faster. > > I think most or all calls to `urlparse()` can be replaced with > `urlsplit()`. This make make a small but measurable performance > difference in common paths, such as in `CsrfViewMiddleware` or the test > `Client`. > > See more in this Anthony Sottile video: > https://www.youtube.com/watch?v=ABJvdsIANds New description: Many places in Django use [`urlparse()`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse), which supports the rarely-used “path parameter” syntax (not to be confused with query parameters). The `urlsplit()` function is similar but does not parse such path parameters, which makes it a bit faster. I think most or all calls to `urlparse()` can be replaced with `urlsplit()`, and similarly `urlunparse()` with `urlunsplit()`. This may make a small but measurable performance difference in common paths, such as in `CsrfViewMiddleware` or the test `Client`. See more in this Anthony Sottile video: https://www.youtube.com/watch?v=ABJvdsIANds , where he reports a 3% import time improvement on the Stripe project. -- -- Ticket URL: <https://code.djangoproject.com/ticket/35467#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018f960c6927-e8d8bc04-a6e9-481f-9aba-59fb1ed192a4-000000%40eu-central-1.amazonses.com.