PyMite

A subset of Python for microcontrollers

Site:pymite.python-hosting.com
Author: Dean Hall

. . . lets Python* run in a BILLION new places.

What is PyMite

PyMite is a flyweight Python interpreter written from scratch to execute on 8-bit and larger microcontrollers with resources as limited as 64 KB of program memory (flash) and 4 KB of RAM.

Requirements

Gravy #1 - Easy Porting

Gravy #2 - Hosted Interactive

ipm> import sys; sys.heap()
(4968, 8192)
ipm> map(range, range(5))
[[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3]]
ipm> [chr(x+0x30) for x in range(20) if x%3!=0]
['1','2','4','5','7','8',':',';','=','>','@','A','C']

ipm> l=range(3); import list; list.append(l,"foo")
ipm> d = {}; d['foo'] = l; d['bar'] = chr
ipm> d
{'bar':'<obj type 0x08 @ 0x0000b500>',
'foo':[0, 1, 2, 'foo']}

Gravy #3 - Easiest Native Funcs

def id(o):
    """__NATIVE__
    PmReturn_t retval;
    pPmObj_t pr = C_NULL;
    if (NATIVE_GET_NUM_ARGS() != 1) {
        PM_RAISE(retval, PM_RET_EX_TYPE);
        return retval;
    }
    retval = int_new((int)NATIVE_GET_LOCAL(0), &pr);
    NATIVE_SET_TOS(pr);
    return retval;
    """
    pass

PyMite In Action

ipm> import mbed
ipm> mbed.lcd_print("PyMite r07 on\nMbed-002 14366")
PyMite running on the Mbed board

What's next