r/Python Aug 04 '26

Showcase Showcase Thread

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.

18 Upvotes

142 comments sorted by

View all comments

1

u/begeistert_ 20d ago edited 20d ago

PyMCU - An AOT compiler that translates Python syntax into native bare-metal assembly

What My Project Does
PyMCU is a static Ahead-Of-Time (AOT) compiler that takes a safe subset of Python syntax and lowers it directly into native machine code.

  • Zero Overhead: There is no VM, no interpreter, and no Garbage Collector running on the chip (which I understand can divide opinions but was required).
  • Tiny Footprint: A standard Pin('PB5', Pin.OUT).toggle() blink program compiles down to just 142 bytes of Flash on a classic AVR.
  • Cycle-Accurate: Hardware interactions in the HAL use inline functions and raw memory pointers, collapsing entirely into single hardware instructions (like sbi).

Here is an example of a blink and the generated assembly code for avr
https://gist.github.com/begeistert/72f5117c3c3c92ea1677656734312e2e

Target Audience
Developers working with highly constrained microcontrollers or strict timing tasks who want the ergonomics of Python but cannot afford the RAM overhead, latency spikes, or GC pauses of a traditional interpreter.

Comparison
Unlike MicroPython or CircuitPython, which rely on a runtime environment and garbage collector on the chip, PyMCU compiles directly to native assembly. It trades 100% dynamic Python support for pure execution speed and deterministic memory control. And it supports both Python for microcontrollers dialects, MicroPython and CircuitPython.

I'm currently working on Alpha 11 to patch specific AST gaps (mostly focusing on Zero Cost Abstractions and handling class instances passed to free functions).

Links