summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-02-21 18:26:47 (GMT)
committerGitHub <noreply@github.com>2022-02-21 18:26:47 (GMT)
commit59585d6b2ea50d7bc3a9b336da5bde61367f527c (patch)
tree582cbdf9fd0c4e3b3e19e3474154b1a252a97654 /Python/compile.c
parent0a222db2bca63070f429c0e613707da1bdfaf0e0 (diff)
downloadcpython-59585d6b2ea50d7bc3a9b336da5bde61367f527c.zip
cpython-59585d6b2ea50d7bc3a9b336da5bde61367f527c.tar.gz
cpython-59585d6b2ea50d7bc3a9b336da5bde61367f527c.tar.bz2
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
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 645213b..7f0a6f0 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1800,7 +1800,7 @@ compiler_call_exit_with_nones(struct compiler *c) {
ADDOP_LOAD_CONST(c, Py_None);
ADDOP_LOAD_CONST(c, Py_None);
ADDOP_I(c, PRECALL, 2);
- ADDOP_I(c, CALL, 0);
+ ADDOP_I(c, CALL, 2);
return 1;
}
@@ -4679,16 +4679,12 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e)
if (kwdsl) {
VISIT_SEQ(c, keyword, kwds);
- ADDOP_I(c, PRECALL, argsl + kwdsl);
if (!compiler_call_simple_kw_helper(c, kwds, kwdsl)) {
return 0;
};
- ADDOP_I(c, CALL, kwdsl);
- }
- else {
- ADDOP_I(c, PRECALL, argsl);
- ADDOP_I(c, CALL, 0);
}
+ ADDOP_I(c, PRECALL, argsl + kwdsl);
+ ADDOP_I(c, CALL, argsl + kwdsl);
c->u->u_lineno = old_lineno;
return 1;
}
@@ -4758,7 +4754,7 @@ compiler_joined_str(struct compiler *c, expr_ty e)
ADDOP_I(c, LIST_APPEND, 1);
}
ADDOP_I(c, PRECALL, 1);
- ADDOP_I(c, CALL, 0);
+ ADDOP_I(c, CALL, 1);
}
else {
VISIT_SEQ(c, expr, e->v.JoinedStr.values);
@@ -4927,18 +4923,13 @@ compiler_call_helper(struct compiler *c,
}
if (nkwelts) {
VISIT_SEQ(c, keyword, keywords);
- ADDOP_I(c, PRECALL, n + nelts + nkwelts);
if (!compiler_call_simple_kw_helper(c, keywords, nkwelts)) {
return 0;
};
- ADDOP_I(c, CALL, nkwelts);
- return 1;
- }
- else {
- ADDOP_I(c, PRECALL, n + nelts);
- ADDOP_I(c, CALL, 0);
- return 1;
}
+ ADDOP_I(c, PRECALL, n + nelts + nkwelts);
+ ADDOP_I(c, CALL, n + nelts + nkwelts);
+ return 1;
ex_call: