Shed Skin

Shed Skin is an experimental compiler that translates pure but implicitly statically typed Python programs into optimized . Resulting C++ code can be further compiled as a stand-alone program or extension module. It is similar to projects such as Pyrex, Boo, and RPython.
Details
Shed Skin consists of 7,000 lines of Python code, and a C++ implementation of the Python builtins. It uses the Boehm GC to perform garbage collection.
To deduce type information in order to generate C++ type declarations, such as int, Shed Skin uses type inference techniques. It combines Ole Agesen's Cartesian Product Algorithm with John Plevyak's Iterative Class Splitting technique. As a result, these techniques may limit scaling of program size significantly further than in existing test cases.
Code generated by Shed Skin is completely independent of a Python run-time, which allows use of that code on hardware-constrained embedded systems. Shed Skin can be used for code obfuscation: it is much more difficult to reverse-engineer machine language generated by a C++ compiler than to reverse-engineer Python bytecode.
Restrictions
Variables can only ever have a single type. So e.g. <code>a1; a'1'</code> is not allowed. A single type, however, can be abstract (as in C++), so that e.g. <code>aA(); aB()</code> is allowed, where A and B have a common base class. Programs often must be modified to satisfy the typing restriction, but remain valid Python after modification.
Shed Skin supports only a subset of the features of Python (for example, generator expressions and nested classes/functions are not supported).
Programs cannot freely use the Python standard library, but several common imports are supported, such as random, re, string, os, and sys.
Shed Skin is currently limited to small programs, that do not make heavy use of the Python standard library. The largest program translated to date is 1,600 lines, including comments.
Tests
For a set of test cases developed by Shed Skin's author, code generated by Shed Skin ran 2-40 times faster than did the same code optimized using Psyco's <code>psyco.full()</code> method. However, Shed Skin can also be significantly slower than CPython for some programs compilable by Shed Skin.
 
< Prev   Next >