Local Variables: Stack Efficiency for Minimal RAM

MicroPython optimizes local variable storage by efficiently allocating them on the stack for function calls, rather than as separate heap objects, which reduces memory fragmentation and overhead, making function execution more memory-lean, especially in recursive or frequently called functions.

Sources

Open the full topic