Serhiy Storchaka added the comment:

Yes, it is expected perf regression compared to Python 3.5 and 2.7 when pass 
keyword arguments and single var-keyword argument (because 3.6 uses 
BUILD_MAP_UNPACK_WITH_CALL, while 2.7 and 3.5 don't need it for this case). In 
case of multiple var-keyword arguments (all versions need 
BUILD_MAP_UNPACK_WITH_CALL) even unpatched 3.6 is faster than 3.5.

$ ./python -m timeit -s "def f(**kw): pass" -s "b = {'b': 2}" -- "f(a=1, **b)"
Python 2.7:            100000 loops, best of 3: 2.21 usec per loop
Python 3.5:            100000 loops, best of 3: 4.31 usec per loop
Python 3.6 unpatched:  100000 loops, best of 3: 7.64 usec per loop
Python 3.6 patched:    100000 loops, best of 3: 3.14 usec per loop

$ ./python -m timeit -s "def f(**kw): pass" -s "a = {'a': 1}; b = {'b': 2}" -- 
"f(**a, **b)"
Python 3.5:            100000 loops, best of 3: 11.6 usec per loop
Python 3.6 unpatched:  100000 loops, best of 3: 6.93 usec per loop
Python 3.6 patched:    100000 loops, best of 3: 2.66 usec per loop

$ ./python -m timeit -s "def f(a=None, b=None): pass" -s "b = {'b': 2}" -- 
"f(a=1, **b)"
Python 2.7:            100000 loops, best of 3: 1.97 usec per loop
Python 3.5:            100000 loops, best of 3: 3.75 usec per loop
Python 3.6 unpatched:  100000 loops, best of 3: 7.27 usec per loop
Python 3.6 patched:    100000 loops, best of 3: 2.83 usec per loop

$ ./python -m timeit -s "def f(a=None, b=None): pass" -s "a = {'a': 1}; b = 
{'b': 2}" -- "f(**a, **b)"
Python 3.5:            100000 loops, best of 3: 10.6 usec per loop
Python 3.6 unpatched:  100000 loops, best of 3: 6.47 usec per loop
Python 3.6 patched:    100000 loops, best of 3: 2.31 usec per loop

----------

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

Reply via email to