mirror of
https://github.com/python/cpython.git
synced 2025-08-24 02:35:59 +00:00
gh-126835: Move constant tuple folding from ast_opt to CFG (#130769)
This commit is contained in:
parent
54efe296bc
commit
75103d975c
9 changed files with 264 additions and 172 deletions
|
@ -1688,11 +1688,26 @@ codegen_typealias(compiler *c, stmt_ty s)
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
static bool
|
||||
is_const_tuple(asdl_expr_seq *elts)
|
||||
{
|
||||
for (Py_ssize_t i = 0; i < asdl_seq_LEN(elts); i++) {
|
||||
expr_ty e = (expr_ty)asdl_seq_GET(elts, i);
|
||||
if (e->kind != Constant_kind) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Return false if the expression is a constant value except named singletons.
|
||||
Return true otherwise. */
|
||||
static bool
|
||||
check_is_arg(expr_ty e)
|
||||
{
|
||||
if (e->kind == Tuple_kind) {
|
||||
return !is_const_tuple(e->v.Tuple.elts);
|
||||
}
|
||||
if (e->kind != Constant_kind) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue