A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://microbit-micropython.readthedocs.io/en/latest/micropython.html below:

Website Navigation


MicroPython — BBC micro:bit MicroPython 1.1.1 documentation

MicroPython

Access and control MicroPython internals.

Functions
micropython.const(expr)

Used to declare that the expression is a constant so that the compiler can optimise it. The use of this function should be as follows:

from micropython import const
CONST_X = const(123)
CONST_Y = const(2 * CONST_X + 1)

Constants declared this way are still accessible as global variables from outside the module they are declared in. On the other hand, if a constant begins with an underscore then it is hidden, it is not available as a global variable, and does not take up any memory during execution.

micropython.opt_level([level])

If level is given then this function sets the optimisation level for subsequent compilation of scripts, and returns None. Otherwise it returns the current optimisation level.

The optimisation level controls the following compilation features:

The default optimisation level is usually level 0.

micropython.mem_info([verbose])

Print information about currently used memory. If the verbose argument is given then extra information is printed.

micropython.qstr_info([verbose])

Print information about currently interned strings. If the verbose argument is given then extra information is printed.

This includes the number of interned strings and the amount of RAM they use. In verbose mode it prints out the names of all RAM-interned strings.

micropython.stack_use()

Return an integer representing the current amount of stack that is being used. The absolute value of this is not particularly useful, rather it should be used to compute differences in stack usage at different points.

micropython.heap_lock()
micropython.heap_unlock()

Lock or unlock the heap. When locked no memory allocation can occur and a MemoryError will be raised if any heap allocation is attempted.

micropython.kbd_intr(chr)

Set the character that will raise a KeyboardInterrupt exception. By default this is set to 3 during script execution, corresponding to Ctrl-C. Passing -1 to this function will disable capture of Ctrl-C, and passing 3 will restore it.

This function can be used to prevent the capturing of Ctrl-C on the incoming stream of characters that is usually used for the REPL, in case that stream is used for other purposes


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4