[New-bugs-announce] [issue39320] Handle unpacking of */** arguments and rvalues in the compiler

Mark Shannon report at bugs.python.org
Mon Jan 13 07:28:10 EST 2020


New submission from Mark Shannon <mark at hotpy.org>:

Currently the unpacking of starred values in arguments and the right hand side of assignments is handled in the interpreter without any help from the compiler.
The layout of arguments and values is visible to the compiler, so the compiler should do more of the work.

We can replace the complex bytecodes used in unpacking with simpler more focused ones.
Specifically the collection building operations 
BUILD_LIST_UNPACK, BUILD_TUPLE_UNPACK, BUILD_SET_UNPACK and BUILD_TUPLE_UNPACK_WITH_CALL
can be replaced with simpler, and self-explanatory operations:
LIST_TO_TUPLE, LIST_EXTEND, SET_UPDATE

In addition, the mapping operations
BUILD_MAP_UNPACK and BUILD_MAP_UNPACK_WITH_CALL
can be replaced with DICT_UPDATE and DICT_MERGE.

DICT_MERGE is like DICT_UPDATE but raises an exception for duplicate keys.

This change would not have much of an effect of performance, as the bytecodes listed are relatively rarely used, but shrinking the interpreter is always beneficial.

----------
components: Interpreter Core
messages: 359901
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Handle unpacking of */** arguments and rvalues in the compiler
type: performance
versions: Python 3.9

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


More information about the New-bugs-announce mailing list