opshin
opshin copied to clipboard
Inline constant expressions that are only read once
This enables optimizations that concern making more readable code more efficient. For example the following
def validator(x: int):
y = x
z = y * 2
w = z + 4
return w
will now be computationally as cheap as the spaghetti-ized version
def validator(x: int):
return (x*2)+4
The optimization is only applied to variables that are read once (at this moment there is no setting to change this). In the case of reading and writing exactly once, this optimization will alway lead to less CPU/Mem steps and smaller script size. When applying the optimization to values read more than once, it may lead to a tradeoff of less steps but larger size (depending on the size of the expression that needs to be re-computed it might also increase the steps)