[New-bugs-announce] [issue42033] Seemingly unnecessary complexification of foo(**kw)

Xavier Morel report at bugs.python.org
Wed Oct 14 06:48:31 EDT 2020


New submission from Xavier Morel <xavier.morel at masklinn.net>:

Following bpo-39320 the highly specialised bytecode for vararg calls were replaced by simpler ones, but there seems to be at least one area where the generated bytecode regressed for possibly no reason?

In Python 3.8, foo(**var) compiles to:

0 LOAD_GLOBAL              0 (foo)
2 BUILD_TUPLE              0
4 LOAD_FAST                2 (var)
6 CALL_FUNCTION_EX         1

In Python 3.9, it compiles to:

0 LOAD_GLOBAL              0 (foo)
2 BUILD_TUPLE              0
4 BUILD_MAP                0
6 LOAD_FAST                2 (var)
8 DICT_MERGE               1
0 CALL_FUNCTION_EX         1

The PR 18141 does not seem to change the implementation of CALL_FUNCTION_EX so I would expect that if it was fine with taking the `var` arbitrary mapping before it stil is now, and the extra two opcodes (and creation of a dict) is unnecessary?

----------
messages: 378613
nosy: Mark.Shannon, xmorel
priority: normal
severity: normal
status: open
title: Seemingly unnecessary complexification of foo(**kw)
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42033>
_______________________________________


More information about the New-bugs-announce mailing list