From a5fb699d87ffa178736021c4763d323be54e87d4 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 5 Mar 2018 19:10:45 +1100 Subject: [PATCH] docs/library/micropython: Describe optimisation levels for opt_level(). --- docs/library/micropython.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/library/micropython.rst b/docs/library/micropython.rst index d1f923e31f..a6ea738ed5 100644 --- a/docs/library/micropython.rst +++ b/docs/library/micropython.rst @@ -33,6 +33,18 @@ Functions compilation of scripts, and returns ``None``. Otherwise it returns the current optimisation level. + The optimisation level controls the following compilation features: + + - Assertions: at level 0 assertion statements are enabled and compiled into the + bytecode; at levels 1 and higher assertions are not compiled. + - Built-in ``__debug__`` variable: at level 0 this variable expands to ``True``; + at levels 1 and higher it expands to ``False``. + - Source-code line numbers: at levels 0, 1 and 2 source-code line number are + stored along with the bytecode so that exceptions can report the line number + they occurred at; at levels 3 and higher line numbers are not stored. + + The default optimisation level is usually level 0. + .. function:: alloc_emergency_exception_buf(size) Allocate *size* bytes of RAM for the emergency exception buffer (a good