Python on a micro-controller sounds like a dream - now it has come true. You can download and start working with it today and a development board is soon to be released.
There are other versions of Python targeting small systems but they are very reduced implementations of the language.
Micro Python is a fairly complete re-implementation of Python 3 in C99 ANSI C. It implements the entire Python 3.4 syntax and the following core datatypes: str (no Unicode support yet), bytes, bytearray, tuple, list, dict, set, array.array, collections.namedtuple, classes and instances. Built-in modules include sys, time, and struct. It claims to compile 99.99% of the standard libarry.
There is also a special module that provides I/O and sensor control. You can write statements like:
import pyb pyb.LED(4).on()
Your next question should be how much does all this take to run?
The answer is that a minimal ARM build needs 80K and with all features it needs 200K on Linux.
" .. aims to be properly compatible with CPython, while sporting a very minimal RAM footprint, a compact compiler, and a fast and efficient runtime. These goals have been met by employing many tricks with pointers and bit stuffing, and placing as much as possible in read-only memory."
You can run it on a PC as a lean version of Python or on a PC used as an appliance say. It is claimed that the PC version runs faster than CPython even when using byte code and a lot faster when compiled to native code.
Micro Python is compiled to a compressed byte code that runs on a VM. There are also some speed optimizations - you can add a decorator that compiles a function to machine code which takes more memory but runs twice as fast. There is also an inline assembler allowing you to hand code anything that really has to be fast.
At the moment the system targets 32-bit ARM and there is a new development system called pyboard on which to use Micro Python thanks to a successful Kickstarter appeal. The Micro Python board, based on a STM32F405 microprocessor clocked at 168Mhz, has 1MB flash and 192KB of RAM. It connects to a PC via a USB port and you can interact with it via a Python command line. It can also compile and run Python scripts without any help from a PC. It has a good range of peripherals - 2 LEDS, Switch, real-time clock, accelerometer and 30 I/O pins - 5 USARTS, 2SPIs, 2 I2C buses, 14 AC pins, 2 DAC and 4 servo pins.
The pyboard is supported by the pyb module which includes function to turn on LEDs, sense switches, read the accelerometer, control servos. There are also functions fo the real time clock, UART, I2C and so on.
If you want to get Micro Python working on another development board then you will have to re-implement the pyb module. Don't expect an Arduino implementation any time soon as the Uno, for example, just doesn't have the memory for it. A Raspberry Pi version would certainly be possible.
The pyboard is currently being delivered to the Kickstarter pledges and when this is complete it will go on general sale. There's no price as yet, but from the Kickstarter pledges $50 seems about right. You can also make use of standard modules to add WiFi and Ethernet.
Micro Python and the pyboard are open source and you can get source code and schematics.
It seems incredible that in the 21st century schools are still teaching children to scratch marks on paper. Well in Finland they are taking a step in the direction of the future by giving up teaching [ ... ]