@@ -1122,7 +1122,8 @@ iterations of the loop.
1122
1122
This bytecode distinguishes two cases: if ``STACK[-1] `` has a method with the
1123
1123
correct name, the bytecode pushes the unbound method and ``STACK[-1] ``.
1124
1124
``STACK[-1] `` will be used as the first argument (``self ``) by :opcode: `CALL `
1125
- when calling the unbound method. Otherwise, ``NULL `` and the object returned by
1125
+ or :opcode: `CALL_KW ` when calling the unbound method.
1126
+ Otherwise, ``NULL `` and the object returned by
1126
1127
the attribute lookup are pushed.
1127
1128
1128
1129
.. versionchanged :: 3.12
@@ -1390,32 +1391,48 @@ iterations of the loop.
1390
1391
1391
1392
.. opcode :: CALL (argc)
1392
1393
1393
- Calls a callable object with the number of arguments specified by ``argc ``,
1394
- including the named arguments specified by the preceding
1395
- :opcode: `KW_NAMES `, if any.
1396
- On the stack are (in ascending order), either:
1394
+ Calls a callable object with the number of arguments specified by ``argc ``.
1395
+ On the stack are (in ascending order):
1397
1396
1398
- * NULL
1399
1397
* The callable
1400
- * The positional arguments
1401
- * The named arguments
1402
-
1403
- or:
1404
-
1405
- * The callable
1406
- * ``self ``
1398
+ * ``self `` or ``NULL ``
1407
1399
* The remaining positional arguments
1408
- * The named arguments
1409
1400
1410
- ``argc `` is the total of the positional and named arguments, excluding
1411
- ``self `` when a ``NULL `` is not present.
1401
+ ``argc `` is the total of the positional arguments, excluding ``self ``.
1412
1402
1413
1403
``CALL `` pops all arguments and the callable object off the stack,
1414
1404
calls the callable object with those arguments, and pushes the return value
1415
1405
returned by the callable object.
1416
1406
1417
1407
.. versionadded :: 3.11
1418
1408
1409
+ .. versionchanged :: 3.13
1410
+ The callable now always appears at the same position on the stack.
1411
+
1412
+ .. versionchanged :: 3.13
1413
+ Calls with keyword arguments are now handled by :opcode: `CALL_KW `.
1414
+
1415
+
1416
+ .. opcode :: CALL_KW (argc)
1417
+
1418
+ Calls a callable object with the number of arguments specified by ``argc ``,
1419
+ including one or more named arguments. On the stack are (in ascending order):
1420
+
1421
+ * The callable
1422
+ * ``self `` or ``NULL ``
1423
+ * The remaining positional arguments
1424
+ * The named arguments
1425
+ * A :class: `tuple ` of keyword argument names
1426
+
1427
+ ``argc `` is the total of the positional and named arguments, excluding ``self ``.
1428
+ The length of the tuple of keyword argument names is the number of named arguments.
1429
+
1430
+ ``CALL_KW `` pops all arguments, the keyword names, and the callable object
1431
+ off the stack, calls the callable object with those arguments, and pushes the
1432
+ return value returned by the callable object.
1433
+
1434
+ .. versionadded :: 3.13
1435
+
1419
1436
1420
1437
.. opcode :: CALL_FUNCTION_EX (flags)
1421
1438
@@ -1441,15 +1458,6 @@ iterations of the loop.
1441
1458
.. versionadded :: 3.11
1442
1459
1443
1460
1444
- .. opcode :: KW_NAMES (consti)
1445
-
1446
- Prefixes :opcode: `CALL `.
1447
- Stores a reference to ``co_consts[consti] `` into an internal variable
1448
- for use by :opcode: `CALL `. ``co_consts[consti] `` must be a tuple of strings.
1449
-
1450
- .. versionadded :: 3.11
1451
-
1452
-
1453
1461
.. opcode :: MAKE_FUNCTION
1454
1462
1455
1463
Pushes a new function object on the stack built from the code object at ``STACK[1] ``.
0 commit comments