classification
Title: Simplify urllib.parse_qsl
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cito, corona10, miss-islington, robertohueso
Priority: normal Keywords: patch

Created on 2021-04-29 19:29 by cito, last changed 2021-05-01 00:06 by corona10. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25756 merged corona10, 2021-04-30 18:18
Messages (8)
msg392345 - (view) Author: Christoph Zwerschke (cito) * Date: 2021-04-29 19:29
Just noticed the following code in urrlib.parse_qsl:

    pairs = [s1 for s1 in qs.split(separator)]
    for name_value in pairs:
        ...

see https://github.com/python/cpython/blob/088a15c49d99ecb4c3bef93f8f40dd513c6cae3b/Lib/urllib/parse.py#L755

This looks like an unnecessary list comprehension to me, probably a relic of earlier code that used a nested list comprehension for splitting with two different separators.

Can't we just do this instead now, which is faster and shorter?

   for name_value qs.split(separator):

I can provide a PR if wanted.
msg392369 - (view) Author: Roberto Hueso (robertohueso) * Date: 2021-04-30 00:25
Seems like a nice simplification to me. Can I open PR? :)
msg392486 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-04-30 17:59
> I can provide a PR if wanted.

Please submit the PR if you want
msg392489 - (view) Author: Christoph Zwerschke (cito) * Date: 2021-04-30 18:08
I saw you submitted a PR already which looks good to me.
msg392490 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-04-30 18:12
> I saw you submitted a PR already which looks good to me.

I should care that you can have a chance to submit the patch :)
Is it okay to proceed with this issue with the PR which I closed or do you want to open a PR with your hand?
msg392491 - (view) Author: Christoph Zwerschke (cito) * Date: 2021-04-30 18:16
I don't mind if you reopen your PR. But thanks for asking.
msg392492 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-04-30 18:20
> I don't mind if you reopen your PR. But thanks for asking.

I add your name as the co-author on PR 25756 :)
Thanks for the report and suggestion
msg392504 - (view) Author: miss-islington (miss-islington) Date: 2021-04-30 19:02
New changeset 6143fcdf8bfe54c24e3081bcee423f4d51f35c4e by Dong-hee Na in branch 'master':
bpo-43979: Remove unnecessary operation from urllib.parse.parse_qsl (GH-25756)
https://github.com/python/cpython/commit/6143fcdf8bfe54c24e3081bcee423f4d51f35c4e
History
Date User Action Args
2021-05-01 00:06:39corona10setresolution: fixed
2021-05-01 00:06:33corona10setstatus: open -> closed
stage: patch review -> resolved
2021-04-30 19:02:05miss-islingtonsetnosy: + miss-islington
messages: + msg392504
2021-04-30 18:38:49corona10setversions: + Python 3.10
2021-04-30 18:20:28corona10setmessages: + msg392492
2021-04-30 18:18:12corona10setpull_requests: + pull_request24449
2021-04-30 18:16:53citosetmessages: + msg392491
2021-04-30 18:14:16corona10setversions: - Python 3.6, Python 3.7, Python 3.8, Python 3.9, Python 3.10
2021-04-30 18:12:27corona10setmessages: + msg392490
2021-04-30 18:08:05citosetmessages: + msg392489
2021-04-30 17:59:58corona10setmessages: + msg392486
2021-04-30 17:59:39corona10setpull_requests: - pull_request24446
2021-04-30 16:38:08corona10setkeywords: + patch
nosy: + corona10

pull_requests: + pull_request24446
stage: patch review
2021-04-30 00:25:46robertohuesosetnosy: + robertohueso
messages: + msg392369
2021-04-29 19:29:25citocreate