pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/59585d6b2ea50d7bc3a9b336da5bde61367f527c

ylesheet" href="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> bpo-46329: Streamline calling sequence a bit. (GH-31465) · python/cpython@59585d6 · GitHub
Skip to content

Commit 59585d6

Browse files
authored
bpo-46329: Streamline calling sequence a bit. (GH-31465)
* Move handling of bound-methods to PRECALL. * Remove call_shape.postcall_shrink * Remove call_shape.callable * Remove call_shape.callable. Change CALL oparg to match PRECALL oparg. * Move KW_NAMES before PRECALL. * Update opcode docs in dis.rst
1 parent 0a222db commit 59585d6

7 files changed

Lines changed: 218 additions & 178 deletions

File tree

Doc/library/dis.rst

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ the following command can be used to display the disassembly of
3636
>>> dis.dis(myfunc)
3737
1 0 RESUME 0
3838

39-
2 2 LOAD_GLOBAL 0 (len)
40-
4 LOAD_FAST 0 (alist)
41-
6 PRECALL_FUNCTION 1
42-
8 CALL 0
43-
10 RETURN_VALUE
39+
2 2 PUSH_NULL
40+
4 LOAD_GLOBAL 0 (len)
41+
6 LOAD_FAST 0 (alist)
42+
8 PRECALL 1
43+
10 CALL 1
44+
12 RETURN_VALUE
4445

4546
(The "2" is a line number).
4647

@@ -106,9 +107,10 @@ Example::
106107
... print(instr.opname)
107108
...
108109
RESUME
110+
PUSH_NULL
109111
LOAD_GLOBAL
110112
LOAD_FAST
111-
PRECALL_FUNCTION
113+
PRECALL
112114
CALL
113115
RETURN_VALUE
114116

@@ -1063,18 +1065,28 @@ iterations of the loop.
10631065
with ``__cause__`` set to ``TOS``)
10641066

10651067

1066-
.. opcode:: CALL (named)
1068+
.. opcode:: CALL (argc)
10671069

1068-
Calls a callable object with the number of positional arguments specified by
1069-
the preceding :opcode:`PRECALL_FUNCTION` or :opcode:`PRECALL_METHOD` and
1070-
the named arguments specified by the preceding :opcode:`KW_NAMES`, if any.
1071-
*named* indicates the number of named arguments.
1072-
On the stack are (in ascending order):
1070+
Calls a callable object with the number of arguments specified by ``argc``,
1071+
including the named arguments specified by the preceding
1072+
:opcode:`KW_NAMES`, if any.
1073+
On the stack are (in ascending order), either:
10731074

1075+
* NULL
10741076
* The callable
10751077
* The positional arguments
10761078
* The named arguments
10771079

1080+
or:
1081+
1082+
* The callable
1083+
* ``self``
1084+
* The remaining positional arguments
1085+
* The named arguments
1086+
1087+
``argc`` is the total of the positional and named arguments, excluding
1088+
``self`` when a ``NULL`` is not present.
1089+
10781090
``CALL`` pops all arguments and the callable object off the stack,
10791091
calls the callable object with those arguments, and pushes the return value
10801092
returned by the callable object.
@@ -1102,33 +1114,34 @@ iterations of the loop.
11021114
Loads a method named ``co_names[namei]`` from the TOS object. TOS is popped.
11031115
This bytecode distinguishes two cases: if TOS has a method with the correct
11041116
name, the bytecode pushes the unbound method and TOS. TOS will be used as
1105-
the first argument (``self``) by :opcode:`PRECALL_METHOD` when calling the
1117+
the first argument (``self``) by :opcode:`CALL` when calling the
11061118
unbound method. Otherwise, ``NULL`` and the object return by the attribute
11071119
lookup are pushed.
11081120

11091121
.. versionadded:: 3.7
11101122

11111123

1112-
.. opcode:: PRECALL_METHOD (argc)
1124+
.. opcode:: PRECALL (argc)
11131125

1114-
Prefixes :opcode:`CALL` (possibly with an intervening ``KW_NAMES``).
1115-
This opcode is designed to be used with :opcode:`LOAD_METHOD`.
1116-
Sets internal variables, so that :opcode:`CALL`
1117-
clean up after :opcode:`LOAD_METHOD` correctly.
1126+
Prefixes :opcode:`CALL`. Logically this is a no op.
1127+
It exists to enable effective specialization of calls.
1128+
``argc`` is the number of arguments as described in :opcode:`CALL`.
11181129

11191130
.. versionadded:: 3.11
11201131

11211132

1122-
.. opcode:: PRECALL_FUNCTION (args)
1133+
.. opcode:: PUSH_NULL
11231134

1124-
Prefixes :opcode:`CALL` (possibly with an intervening ``KW_NAMES``).
1125-
Sets internal variables, so that :opcode:`CALL` can execute correctly.
1135+
Pushes a ``NULL`` to the stack.
1136+
Used in the call sequence to match the ``NULL`` pushed by
1137+
:opcode:`LOAD_METHOD` for non-method calls.
11261138

11271139
.. versionadded:: 3.11
11281140

11291141

11301142
.. opcode:: KW_NAMES (i)
11311143

1144+
Prefixes :opcode:`PRECALL`.
11321145
Stores a reference to ``co_consts[consti]`` into an internal variable
11331146
for use by :opcode:`CALL`. ``co_consts[consti]`` must be a tuple of strings.
11341147

Lib/importlib/_bootstrap_external.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def _write_atomic(path, data, mode=0o666):
386386
# ROT_TWO/ROT_THREE/ROT_FOUR/ROT_N with SWAP)
387387
# Python 3.11a5 3478 (New CALL opcodes)
388388
# Python 3.11a5 3479 (Add PUSH_NULL opcode)
389+
# Python 3.11a5 3480 (New CALL opcodes, second iteration)
389390

390391
# Python 3.12 will start with magic number 3500
391392

@@ -403,7 +404,7 @@ def _write_atomic(path, data, mode=0o666):
403404
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
404405
# in PC/launcher.c must also be updated.
405406

406-
MAGIC_NUMBER = (3479).to_bytes(2, 'little') + b'\r\n'
407+
MAGIC_NUMBER = (3480).to_bytes(2, 'little') + b'\r\n'
407408
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
408409

409410
_PYCACHE = '__pycache__'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy