mirror of
https://github.com/python/cpython.git
synced 2025-09-09 02:11:51 +00:00
GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)
This commit is contained in:
parent
987b4bc087
commit
22e65eecaa
22 changed files with 719 additions and 508 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue