Radar van Elk Solutions

Hackaday · Creativity & design

CircuitPython Turbo Boosts Performance

CircuitPython, a beginner-friendly programming language, now offers significant speed improvements through a new feature called CircuitPython Turbo.

CircuitPython, like BASIC, is easy to write but traditionally slow due to its interpreted nature. CircuitPython Turbo, developed by Mikey Sklar with assistance from Anthropic's Claude LLM, allows critical code sections to be pre-compiled, overcoming these speed limitations.

This new feature is similar to MicroPython's 'Viper' compiler. CircuitPython, a fork of MicroPython, now incorporates this capability, which was previously absent.

Before Turbo, CircuitPython ran solely in interpreted mode. With Turbo, sections can be marked as 'native', compiling instructions while retaining Python objects, yielding approximately a 3x speedup.

Further optimization using 'viper' mode, which requires declaring variables and pointers, can achieve speedups ranging from 20x to 70x, depending on the task.

Adafruit's documentation shows a Metro RP2040 calculating the Mandelbrot set 3x faster in Native mode and 19.7 times faster in Viper mode compared to standard Python bytecode.

While CircuitPython Turbo does not include inline assembly, a feature present in upstream MicroPython, its potential applications on microcontrollers are broad, from e-bikes to music players.

AI-samenvatting op basis van de bron.

Hackaday