PyMite: Python-on-a-chip

Python-on-a-Chip (p14p) is a project to develop a reduced Python virtual machine (codenamed PyMite) that runs a significant subset of the Python language on microcontrollers without an OS. The other parts of p14p are the device drivers, high-level libraries and other tools. They’ve released ports for the Microchip PIC/24dcPIC, Teensy 2.0, Arduino Mega and others. Here is their PyCon 2011 Lightning Talk slide presentation.

Some features of PyMite include a memory requirement of roughly 55 KB program memory, supports integers, floats, tuples, lists, dicts, functions, modules, classes, generators, decorators and closures, supports 25 of 29 keywords and 89 of 112 bytecodes from Python 2.6 and is licensed under the GNU GPL ver. 2. However, it lacks a built-in compiler, and does not include any of Python’s libraries. If you know C, Python and how to work with microcontrollers, it might be worth checking out.

That’s almost the entire standard library (http://docs.python.org/library/). Most of the modules left after trimming all of that probably aren’t slim enough to work as-is in a tiny environment like this.

The system requirements are interesting; it’s an exceptionally tight fit on a few of the platforms they’ve implemented. Really cool stuff; I’d love to see what they could come up with if they put their heads together with the PyPy guys. :)

It makes sense if your micro controller has some form of host controlled storage like a USB OTG/Host controller with a stick plugged in or SD card. You could then offer a microcontroller specific Python library and use python as a soft glue for functionality. eg. Write a Python script, plug it into the MCU, and watch it run!