When qlasskit parses expressions containing constants, the boolean form containing the constant is created and then optimized (if possible). A smarter approach would be to evaluate constant expression during ast2logic parsing.
This could be performed by calling eval if tleft and tright are ast.Constant in a binop. But we also need to evalute op(const).
Test case:
a + (13 - 12 + 1) => a + 2
a + len([12]) => a + 1
if True then b else c => b
Since ast2ast is getting bigger, we can separate it to different rewriters, so we can simplify the file, and have a prioritization of certain optimizations.
When qlasskit parses expressions containing constants, the boolean form containing the constant is created and then optimized (if possible). A smarter approach would be to evaluate constant expression during ast2logic parsing.
This could be performed by calling
eval
if tleft and tright are ast.Constant in a binop. But we also need to evalute op(const).Test case:
Since ast2ast is getting bigger, we can separate it to different rewriters, so we can simplify the file, and have a prioritization of certain optimizations.