From 59585d6b2ea50d7bc3a9b336da5bde61367f527c Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Mon, 21 Feb 2022 18:26:47 +0000 Subject: 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 --- Python/compile.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'Python/compile.c') diff --git a/Python/compile.c b/Python/compile.c index 645213b192..7f0a6f096d 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: -- cgit v1.2.1