07.02.20 01:00, Guido van Rossum пише:
How did we move from [*a,...] to print(*a,...)? They are quite different.
They are quite similar. The code for `(*a, *b, *c)` is:
1 0 LOAD_NAME 0 (a)
2 LOAD_NAME 1 (b)
4 LOAD_NAME 2 (c)
6 BUILD_TUPLE_UNPACK 3
The code for `print(*a, *b, *c)` is:
1 0 LOAD_NAME 0 (print)
2 LOAD_NAME 1 (a)
4 LOAD_NAME 2 (b)
6 LOAD_NAME 3 (c)
8 BUILD_TUPLE_UNPACK_WITH_CALL 3
10 CALL_FUNCTION_EX 0
It is covered by PEP 448 [1].
* BUILD_TUPLE_UNPACK, BUILD_LIST_UNPACK, BUILD_SET_UNPACK and
BUILD_MAP_UNPACK were used to unpack iterables or mappings in tuple,
list, set and dict displays.
* BUILD_TUPLE_UNPACK_WITH_CALL and BUILD_MAP_UNPACK_WITH_CALL were used
when pass multiple var-positional and var-keyword arguments to a function.
All of them except BUILD_TUPLE_UNPACK_WITH_CALL was added in issue2292
[2]. BUILD_TUPLE_UNPACK_WITH_CALL was added in issue28257 [3] to unify
error messages.
[1] https://www.python.org/dev/peps/pep-0448/
[2] https://bugs.python.org/issue2292
[3] https://bugs.python.org/issue28257
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/45LN7WN4377W2HGHEW3NJL6ORORJSM3A/
Code of Conduct: http://python.org/psf/codeofconduct/