New submission from Serhiy Storchaka:

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.

----------
components: Interpreter Core
files: PyArg_ParseTupleAndKeywords-faster-positional-args-parse.patch
keywords: patch
messages: 283711
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Faster positional arguments parsing in PyArg_ParseTupleAndKeywords
type: performance
versions: Python 3.7
Added file: 
http://bugs.python.org/file45977/PyArg_ParseTupleAndKeywords-faster-positional-args-parse.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29029>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to