HOME

TheInfoList



OR:

Shed Skin is an experimental restricted-
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
(3.8+) to
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
programming language
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
. It can translate pure, but implicitly statically typed Python programs into optimized C++. It can generate stand-alone programs or extension modules that can be imported and used in larger Python programs. Shed Skin is an open source project with contributions from many people, however the main author is Mark Dufour. Work has been going into Shed Skin since 2005.first Shed Skin release
/ref>


Features

Besides the typing restriction, programs cannot freely use the Python standard library, although about 20 common modules, such as random, itertools and re (
regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
s), are supported as of 2011. Also, not all Python features, such as
nested function In computer programming, a nested function (or nested procedure or subroutine) is a function which is defined within another function, the ''enclosing function''. Due to simple recursive scope rules, a nested function is itself invisible outside ...
s and variable numbers of arguments, are supported. Many introspective dynamic parts of the language are unsupported. For example, functions like getattr, and hasattr are unsupported. As of May 2011,
Unicode Unicode, formally The Unicode Standard,The formal version reference is is an information technology standard for the consistent encoding, representation, and handling of text expressed in most of the world's writing systems. The standard, wh ...
is not supported. As of June 2016 for a set of 75 non-trivial test programs (at over 25,000 lines of code in total), measurements show a typical speedup of 2-20 times over
Psyco Psyco is an unmaintained specializing just-in-time compiler for pre-2.7 Python originally developed by Armin Rigo and further maintained and developed by Christian Tismer. Development ceased in December, 2011. Psyco ran on BSD-derived opera ...
, and 2-200 times over
CPython CPython is the reference implementation of the Python programming language. Written in C and Python, CPython is the default and most widely used implementation of the Python language. CPython can be defined as both an interpreter and a compi ...
.Speed up your Python: Unladen vs. Shed Skin vs. PyPy vs. Cython vs. C
/ref>Taking on Shed-Skin
/ref>Speeding up Python code with Shed Skin
/ref>MiniLight, minimal global illumination renderer benchmark
/ref> Shed Skin is still in an early stage of development, so many other programs will not compile unmodified.Shed Skin webpage
/ref> Shed Skin can be used to generate standalone executables which need only the C++ runtime libraries. It can also be used to generate CPython modules. This allows compiling parts of larger programs with Shed Skin, while running the other parts using regular CPython. Another use has been to wrap C++ classes using Shed Skin to allow C++ classes to be used as Python classes.Wrapping C++ classes using Shed Skin
/ref> The license of the Shed Skin source code is under two parts. The main compiler code is under the
GNU General Public License The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end users the four freedoms to run, study, share, and modify the software. The license was the first copyleft for general ...
(GPL). The supporting code that it uses as a run time library is under a
BSD The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berk ...
or
MIT The Massachusetts Institute of Technology (MIT) is a private land-grant research university in Cambridge, Massachusetts. Established in 1861, MIT has played a key role in the development of modern technology and science, and is one of the m ...
license depending on the module. This allows compiling both GPL and non-GPL programs.


Type inference

Shed Skin combines Ole Agesen's Cartesian Product Algorithm (CPA) with the data-polymorphic part of John Plevyak's Iterative Flow Analysis (IFA).Master Thesis Mark Dufour, "Shed Skin. An Optimizing Python-to-C++ Compiler"
April 19, 2006
Version 0.6 introduced scalability improvements which repeatedly analyze larger versions of a program (in addition to the mentioned techniques), until it is fully analyzed. This allows Shed Skin to do
type inference Type inference refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some branches of computer science and linguistic ...
on larger programs than previously. It starts with an empty callgraph, essentially, and slowly adds to it, until the whole call graph has been added. A graph has been published by the author, showing analysis times for 50 example programs, at a total of around 15,000 lines.Type inference scalability
2010-12


Modules

For version 0.9 the following 25 modules are largely supported.