Skip to content

Commit a5fb699

Browse files
committed
docs/library/micropython: Describe optimisation levels for opt_level().
1 parent 6e09320 commit a5fb699

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

docs/library/micropython.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ Functions
3333
compilation of scripts, and returns ``None``. Otherwise it returns the current
3434
optimisation level.
3535

36+
The optimisation level controls the following compilation features:
37+
38+
- Assertions: at level 0 assertion statements are enabled and compiled into the
39+
bytecode; at levels 1 and higher assertions are not compiled.
40+
- Built-in ``__debug__`` variable: at level 0 this variable expands to ``True``;
41+
at levels 1 and higher it expands to ``False``.
42+
- Source-code line numbers: at levels 0, 1 and 2 source-code line number are
43+
stored along with the bytecode so that exceptions can report the line number
44+
they occurred at; at levels 3 and higher line numbers are not stored.
45+
46+
The default optimisation level is usually level 0.
47+
3648
.. function:: alloc_emergency_exception_buf(size)
3749

3850
Allocate *size* bytes of RAM for the emergency exception buffer (a good

0 commit comments

Comments
 (0)