circuitpython/tests/micropython/const.py
Damien George ffae48d750 py, compiler: Add basic support for A=const(123).
You can now do:

    X = const(123)
    Y = const(456 + X)

and the compiler will replace X and Y with their values.

See discussion in issue #266 and issue #573.
2014-05-08 15:58:39 +00:00

12 lines
116 B
Python

# test constant optimisation
X = const(123)
Y = const(X + 456)
print(X, Y + 1)
def f():
print(X, Y + 1)
f()