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

Created on 2020-01-13 12:28 by Mark.Shannon, last changed 2021-08-30 09:13 by Mark.Shannon. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17984 merged Mark.Shannon, 2020-01-13 12:50
PR 18141 merged Mark.Shannon, 2020-01-23 09:38
PR 18243 closed brandtbucher, 2020-01-29 03:22
PR 18264 closed brandtbucher, 2020-01-30 01:03
Messages (4)
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.
msg360548 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2020-01-23 09:25
New changeset 13bc13960cc83dbd1cb5701d9a59ac9b9144b205 by Mark Shannon in branch 'master':
bpo-39320: Handle unpacking of *values in compiler (GH-17984)
https://github.com/python/cpython/commit/13bc13960cc83dbd1cb5701d9a59ac9b9144b205
msg360749 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2020-01-27 09:57
New changeset 8a4cd700a7426341c2074a2b580306d2d60ec839 by Mark Shannon in branch 'master':
bpo-39320: Handle unpacking of **values in compiler (GH-18141)
https://github.com/python/cpython/commit/8a4cd700a7426341c2074a2b580306d2d60ec839
msg375260 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-08-12 16:11
These changes introduced a regression: bpo-41531 "Python 3.9 regression: Literal dict with > 65535 items are one item shorter".
History
Date User Action Args
2021-08-30 09:13:18Mark.Shannonsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-08-12 16:11:30vstinnersetnosy: + vstinner
messages: + msg375260
2020-01-30 01:03:05brandtbuchersetpull_requests: + pull_request17641
2020-01-29 03:23:00brandtbuchersetnosy: + brandtbucher
2020-01-29 03:22:40brandtbuchersetpull_requests: + pull_request17623
2020-01-27 09:57:49Mark.Shannonsetmessages: + msg360749
2020-01-23 09:38:11Mark.Shannonsetpull_requests: + pull_request17527
2020-01-23 09:25:21Mark.Shannonsetmessages: + msg360548
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