Skip to content

Commit 8219a84

Browse files
refactor: Use urllib.parse.urlsplit over urlparse (#1997)
* Use urllib.parse.urlsplit over urllib.parse.urlparse to avoid having to deal with urlparse's 'params' argument which incurs a performance cost. - c.f. https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlsplit - c.f. https://youtu.be/ABJvdsIANds
1 parent 43c9ecc commit 8219a84

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pyhf/contrib/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from io import BytesIO
77
from pathlib import Path
88
from shutil import rmtree
9-
from urllib.parse import urlparse
9+
from urllib.parse import urlsplit
1010

1111
from pyhf import exceptions
1212

@@ -50,7 +50,7 @@ def download(archive_url, output_directory, force=False, compress=False):
5050
"""
5151
if not force:
5252
valid_hosts = ["www.hepdata.net", "doi.org"]
53-
netloc = urlparse(archive_url).netloc
53+
netloc = urlsplit(archive_url).netloc
5454
if netloc not in valid_hosts:
5555
raise exceptions.InvalidArchiveHost(
5656
f"{netloc} is not an approved archive host: {', '.join(str(host) for host in valid_hosts)}\n"

0 commit comments

Comments
 (0)