⬆️ ⬇️

Micro Python - an effective implementation of Python 3 for microcontrollers





English developer Damien George (Damien George) today officially announced the release of Micro Python - an effective implementation of Python 3 for embedded systems with a small amount of RAM. The development of this version began in December, after a successful campaign to raise funds for the release of Pyboard - controller operating on Python.



“Although Python has many attractive features, its current implementations (read, CPython) are not suitable for embedded systems such as microcontrollers and small systems on a chip,” writes Damien George. “The reason is that CPython uses an awful lot of RAM — both for the stack and for the heap — even in simple operations like adding whole numbers.”



Micro Python is a new implementation of the Python 3 programming language that needs to be correctly compatible with CPython, while at the same time using minimal RAM, a compact compiler, and high performance in the runtime environment.

')

George explains that he managed to achieve this through several tricks with pointers and code optimization. As a result, Micro Python supports almost all the syntax of Python 3.4 (the work is still ongoing), and most of the scripts take up much less RAM and run noticeably faster than CPython.



The minimum build for ARM fits in 80k, and with all functions under Linux - in 200k. The base REPL environment requires only 2 kilobytes of RAM.



Additionally, Micro Python has two AOT compilations built into the native code, and there is a built-in assembler for writing time-critical applications on the microcontroller.



The implementation is written on C99 ANSI C and compiles normally under Unix (POSIX), Mac OS X, Windows and some ARM microcontrollers.

Source: https://habr.com/ru/post/225131/



All Articles