classification
Title: Handle unpacking of */** arguments and rvalues in the compiler
Type: performance Stage: patch review
Components: Interpreter Core Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, pablogsal
Priority: normal Keywords: patch

Created on 2020-01-13 12:28 by Mark.Shannon, last changed 2020-01-13 14:34 by pablogsal.

Pull Requests
URL Status Linked Edit
PR 17984 open Mark.Shannon, 2020-01-13 12:50
Messages (1)
msg359901 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2020-01-13 12:28
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.
History
Date User Action Args
2020-01-13 14:34:54pablogsalsetnosy: + pablogsal
2020-01-13 12:50:19Mark.Shannonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request17388
2020-01-13 12:28:10Mark.Shannoncreate