◐ Shell
clean mode source ↗

bpo-29469: Optimize literal lists and sets iterating on the AST level. by serhiy-storchaka · Pull Request #4866 · python/cpython

pitrou

return make_const(node, newval, arena);
}

static int

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add comments and/or a "docstring" to explain what this is doing.

pitrou

}

static int
fold_compare(expr_ty node, PyArena *arena)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already is documented inside the function. In future the optimization for literal operands (like 1 < 2) can be added here, but currently it optimizes only the particular case of 'in' and 'not in' operators.

@methane