homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Faster positional arguments parsing in PyArg_ParseTupleAndKeywords
Type: performance Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: methane, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2016年12月20日 21:30 by serhiy.storchaka, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
PyArg_ParseTupleAndKeywords-faster-positional-args-parse.patch serhiy.storchaka, 2016年12月20日 21:30 review
PyArg_ParseTupleAndKeywords-faster-positional-args-parse-2.patch vstinner, 2017年01月16日 23:39 review
Messages (8)
msg283711 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016年12月20日 21:30
Proposed patch speeds up parsing positional arguments in PyArg_ParseTupleAndKeywords().
$ ./python -m perf timeit "1 .to_bytes(1, 'little', signed=False)"
Unpatched: Median +- std dev: 2.01 us +- 0.09 us
Patched: Median +- std dev: 1.23 us +- 0.03 us
Currently names of all passed positional argument are looked up in the kwargs dictionary for checking if the argument is passed as positional and keyword argument. With the patch this is checked only if there are unhandled keyword arguments after parsing keyword arguments that don't passed as positional arguments.
The same optimization also is applied to _PyArg_ParseTupleAndKeywordsFast() and like, but the effect is much smaller.
The patch also includes tiny refactoring.
msg285515 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2017年01月15日 17:25
LGTM
msg285590 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2017年01月16日 23:39
New changeset a36e60c5fee0 by Victor Stinner in branch 'default':
Rename keywords to kwargs in getargs.c
https://hg.python.org/cpython/rev/a36e60c5fee0 
msg285591 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017年01月16日 23:39
Oh, I missed this issue. Since I made minor cleanup recently, I took the liberty of rebasing your patch.
I also pushed your "keywords => kwargs" change, just to make the patch simpler to review.
msg285592 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017年01月16日 23:49
> Unpatched: Median +- std dev: 2.01 us +- 0.09 us
> Patched: Median +- std dev: 1.23 us +- 0.03 us
Oh wow, impressive speedup! As usual, good job Serhiy ;-)
PyArg_ParseTupleAndKeywords-faster-positional-args-parse-2.patch: LGTM! Can you please push it?
msg285617 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2017年01月17日 07:24
LGTM again.
msg285621 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2017年01月17日 08:07
New changeset a8563ef0eb8a by Serhiy Storchaka in branch 'default':
Issue #29029: Speed up processing positional arguments in
https://hg.python.org/cpython/rev/a8563ef0eb8a 
msg285622 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017年01月17日 08:15
Thank you for your reviews Inada and Victor. Thank you for rebasing the patch Victor.
I were going first to try an alternative patch, maybe less efficient, but allowing to share more code. But since the code is changed so fast, it is better to commit the ready patch.
History
Date User Action Args
2022年04月11日 14:58:40adminsetgithub: 73215
2017年01月17日 08:15:00serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg285622

stage: patch review -> resolved
2017年01月17日 08:07:56python-devsetmessages: + msg285621
2017年01月17日 07:24:59methanesetmessages: + msg285617
2017年01月16日 23:49:18vstinnersetmessages: + msg285592
2017年01月16日 23:39:55vstinnersetfiles: + PyArg_ParseTupleAndKeywords-faster-positional-args-parse-2.patch
nosy: + vstinner
messages: + msg285591

2017年01月16日 23:39:01python-devsetnosy: + python-dev
messages: + msg285590
2017年01月15日 17:25:56methanesetnosy: + methane
messages: + msg285515
2016年12月20日 21:30:18serhiy.storchakacreate

AltStyle によって変換されたページ (->オリジナル) /