const(): Compile-Time Memory & Speed Boost

MicroPython's `const()` replaces variable names with literal integer values at compile time, eliminating runtime dictionary lookups and saving RAM. Prepending with an underscore (e.g., `_CONST`) further prevents global dictionary allocation, saving more memory by not being visible outside the module.

Sources

Open the full topic