Constant folding of expressions. For example, 3 + 5 can be constant folded into 8.
Function | constant |
Undocumented |
Function | constant |
Undocumented |
Function | constant |
Return the constant value of an expression for supported operations. |
Function | constant |
Undocumented |
Constant | CONST |
Undocumented |
Type Alias |
|
Undocumented |
Return the constant value of an expression for supported operations. Among other things, support int arithmetic and string concatenation. For example, the expression 3 + 5 has the constant value 8. Also bind simple references to final constants defined in the current module (cur_mod_id). Binding to references is best effort -- we don't bind references to other modules. Mypyc trusts these to be correct in compiled modules, so that it can replace a constant expression (or a reference to one) with the statically computed value. We don't want to infer constant values based on stubs, in particular, as these might not match the implementation (due to version skew, for example). Return None if unsuccessful.