#35467: Prefer urlsplit() over urlparse()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Jake
Type: | Howard
Cleanup/optimization | Status: assigned
Component: Utilities | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jake Howard):
* owner: nobody => Jake Howard
* status: new => assigned
Comment:
From some basic testing, it looks like this should have a nice
improvement:
{{{#!python
In [1]: import urllib.parse
In [2]: %timeit urllib.parse.urlparse("https://example.com")
1.52 µs ± 37.9 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops
each)
In [3]: %timeit urllib.parse.urlsplit("https://example.com")
258 ns ± 1.14 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops
each)
}}}
The difference stays about constant, even with longer URLs. The specifics
will obviously vary by hardware and Python version (the above is 3.12.3),
but ~6x improvement is definitely worthwhile.
--
Ticket URL: <https://code.djangoproject.com/ticket/35467#comment:3>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018f9d2b1f4d-cad02f38-8c59-4214-a1af-18f200672b89-000000%40eu-central-1.amazonses.com.