diff options
author | Angus Gratton <angus@redyak.com.au> | 2022-07-27 12:52:48 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-09-23 16:04:13 +1000 |
commit | 25ff5b52d9786beff0b90a268af813b223f31f57 (patch) | |
tree | 83fdfa31be7243de58f1e555149305eecd10ffd6 /docs/esp8266/tutorial/index.rst | |
parent | f91ebf6fa972a593ede25d33740e693d99dbbc3f (diff) |
py/parse: Allow const types other than int to optimise as true/false.
Allows optimisation of cases like:
import micropython
_DEBUG = micropython.const(False)
if _DEBUG:
print('Debugging info')
Previously the 'if' statement was only optimised out if the type of the
const() argument was integer.
The change is implemented in a way that makes the compiler slightly smaller
(-16 bytes on PYBV11) but compilation will also be very slightly slower.
As a bonus, if const support is enabled then the compiler can now optimise
const truthy/falsey expressions of other types, like:
while "something":
pass
... unclear if that is useful, but perhaps it could be.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'docs/esp8266/tutorial/index.rst')
0 files changed, 0 insertions, 0 deletions