diff options
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/Python/compile.c b/Python/compile.c index 1f08e46..b05c1ad 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4982,9 +4982,13 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e) VISIT_SEQ(c, keyword, kwds); RETURN_IF_ERROR( compiler_call_simple_kw_helper(c, loc, kwds, kwdsl)); + loc = update_start_location_to_match_attr(c, LOC(e), meth); + ADDOP_I(c, loc, CALL_KW, argsl + kwdsl); + } + else { + loc = update_start_location_to_match_attr(c, LOC(e), meth); + ADDOP_I(c, loc, CALL, argsl); } - loc = update_start_location_to_match_attr(c, LOC(e), meth); - ADDOP_I(c, loc, CALL, argsl + kwdsl); return 1; } @@ -5150,7 +5154,7 @@ compiler_subkwargs(struct compiler *c, location loc, } /* Used by compiler_call_helper and maybe_optimize_method_call to emit - * KW_NAMES before CALL. + * a tuple of keyword names before CALL. */ static int compiler_call_simple_kw_helper(struct compiler *c, location loc, @@ -5165,12 +5169,7 @@ compiler_call_simple_kw_helper(struct compiler *c, location loc, keyword_ty kw = asdl_seq_GET(keywords, i); PyTuple_SET_ITEM(names, i, Py_NewRef(kw->arg)); } - Py_ssize_t arg = compiler_add_const(c->c_const_cache, c->u, names); - if (arg < 0) { - return ERROR; - } - Py_DECREF(names); - ADDOP_I(c, loc, KW_NAMES, arg); + ADDOP_LOAD_CONST_NEW(c, loc, names); return SUCCESS; } @@ -5215,8 +5214,11 @@ compiler_call_helper(struct compiler *c, location loc, VISIT_SEQ(c, keyword, keywords); RETURN_IF_ERROR( compiler_call_simple_kw_helper(c, loc, keywords, nkwelts)); + ADDOP_I(c, loc, CALL_KW, n + nelts + nkwelts); + } + else { + ADDOP_I(c, loc, CALL, n + nelts); } - ADDOP_I(c, loc, CALL, n + nelts + nkwelts); return SUCCESS; ex_call: |