Thanks all for the input on this topic. Let me summarise what was said. There was discussion that the ability to change the "optimize" value is not enough and there should be more fine grained control over other flags/settings. Perhaps that is true, but at least for our case in MicroPython there's only one (runtime) optimisation variable and it mimics CPython's -O command line option (affecting __debug__, assert compilation, and whether line numbers are included in the bytecode).
Suggestions for setting the opt level were: 1) sys.set_default_optimize(level), with the existing sys.flags.optimize attribute as the accessor. 2) sys.opt_level, being a read/write attribute 3) sys._setflag(name, value) as implemented by eGenix PyRun I think option 1 is the most consistent with the existing sys module, although the name is rather long and I think sys.set_optimize(level) would be better (after all, none of the other sys.set functions have the word default in them). As a second preference I like micropython.opt_level([value]), which can set and get the value, and keeps it specific to uPy. Cheers, Damien. _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/