PyPy is a
self-hostingThe term self-hosting was coined to refer to the use of a computer program as part of the toolchain or operating system that produces new versions of that same program—for example, a compiler that can compile its own source code. Self-hosting software is commonplace on personal computers and larger...
interpreterIn computer science, an interpreter is a computer program which reads source code written in a high-level programming language, transforms the code to machine code, and executes the machine code. Using an interpreter, a single source file can produce equal results even in vastly different systems...
for the
Python programming languagePython is a general-purpose high-level programming language. Its design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
.
PyPy was conceived as an implementation of Python written in Python, which enables Python developers to hack the implementation. This makes it easy to identify areas where it can be improved. PyPy is also more flexible and easier to experiment with than
CPythonCPython is the default, most-widely used implementation of the Python programming language. It is written in C. In addition to CPython, there are two other production-quality Python implementations: Jython, written in Java, and IronPython, which is written for the Common Language Runtime, as well...
, thus allowing developers to experiment with multiple implementations of specific features.
PyPy aims to provide a common translation and support framework for producing implementations of dynamic languages, emphasising a clean separation between language specification and implementation aspects.
PyPy is a
self-hostingThe term self-hosting was coined to refer to the use of a computer program as part of the toolchain or operating system that produces new versions of that same program—for example, a compiler that can compile its own source code. Self-hosting software is commonplace on personal computers and larger...
interpreterIn computer science, an interpreter is a computer program which reads source code written in a high-level programming language, transforms the code to machine code, and executes the machine code. Using an interpreter, a single source file can produce equal results even in vastly different systems...
for the
Python programming languagePython is a general-purpose high-level programming language. Its design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
.
Details and motivation
PyPy was conceived as an implementation of Python written in Python, which enables Python developers to hack the implementation. This makes it easy to identify areas where it can be improved. PyPy is also more flexible and easier to experiment with than
CPythonCPython is the default, most-widely used implementation of the Python programming language. It is written in C. In addition to CPython, there are two other production-quality Python implementations: Jython, written in Java, and IronPython, which is written for the Common Language Runtime, as well...
, thus allowing developers to experiment with multiple implementations of specific features.
PyPy aims to provide a common translation and support framework for producing implementations of dynamic languages, emphasising a clean separation between language specification and implementation aspects. It also aims to provide a compliant, flexible and fast implementation of the Python programming language using the above framework to enable new advanced features without having to encode low level details into it.
Translation
PyPy consists of a
standard interpreter and a
translator.
The interpreter is a
meta-circular evaluatorA meta-circular evaluator is a special case of a self-interpreter in which the existing facilities of the parent interpreter are directly applied to the source code being interpreted, without any need for additional implementation...
implementing the full Python language in a restricted
subsetIn mathematics, especially in set theory, a set A is a subset of a set B if A is "contained" inside B. Notice that A and B may coincide...
, called RPython (Restricted Python). Unlike standard Python, RPython is statically typed, to allow efficient compilation.
The translator is a tool chain that analyzes RPython code and translates it to a lower-level language, such as
CC is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
,
Java bytecodeJava bytecode is the form of instructions that the Java virtual machine executes. Each bytecode opcode is one byte in length, although some require parameters, resulting in some multi-byte instructions. Not all of the possible 256 opcodes are used...
or
Common Intermediate LanguageCommon Intermediate Language is the lowest-level human-readable programming language in the Common Language Infrastructure and in the .NET Framework. Languages which target the .NET Framework compile to CIL, which is assembled into bytecode...
.
Project status
PyPy is a followup to the
PsycoPsyco is a specializing just-in-time compiler for Python originally developed by Armin Rigo and further maintained and developed by Christian Tismer....
project, a
just-in-timeIn computing, just-in-time compilation , also known as dynamic translation, is a technique for improving the runtime performance of a computer program. JIT builds upon two earlier ideas in run-time environments: bytecode compilation and dynamic compilation...
specializing compilerIn computer science, run-time algorithm specialization is a methodology for creating efficient algorithms for costly computation tasks of certain kinds...
for Python, developed by Armin Rigo. PyPy's aim is to have a just-in-time specializing compiler with scope which was not available for Psyco.
PyPy began as a research and development-oriented project. But after reaching a mature state of development and an official 1.0 release in mid-2007, its current focus is on releasing a production-ready version with more CPython compatibility some time in early 2009. As of June 2008, PyPy is able to run some popular python libraries like Pylons,
PygletPyglet is an OpenGL-based software library used in developing games and other visually-rich applications using the object-oriented language Python....
and
Divmod's NevowNevow is a Python web application framework. Template substitution is achieved via a small Tag Attribute Language which is usually embedded in on-disk XML templates, though there is also a pure-Python domain-specific language called Stan, for expressing this markup programmatically...
.
PyPy was funded by the
European UnionThe European Union is an economic and political union of 27 Member States, located primarily in Europe. Committed to regional integration, the EU was established by the Treaty of Maastricht on 1 November 1993 upon the foundations of the pre-existing European Economic Community...
as a
STRePSpecific Targeted Research Projects are medium-sized research projects funded by the European Commission in the FP6 funding program. STReP projects are composed by a minimum of 3 partners coming from 3 different countries from Associated states. The typical duration of such projects is 2 to 3...
between December 2004 and March 2007. In June 2008, PyPy announced funding as part of the
GoogleGoogle Inc. is an American public corporation, earning revenue from advertising related to its Internet search, e-mail, online mapping, office productivity, social networking, and video sharing services as well as selling advertising-free versions of the same technologies. Google has also...
Open Source programs, and has agreed to focus on making PyPy more compatible with
CPythonCPython is the default, most-widely used implementation of the Python programming language. It is written in C. In addition to CPython, there are two other production-quality Python implementations: Jython, written in Java, and IronPython, which is written for the Common Language Runtime, as well...
.
See also
- Bootstrapping (compilers)
Bootstrapping is a term used in computer science to describe the techniques involved in writing a compiler in the target programming language which it is intended to compile...
- Self-hosting
The term self-hosting was coined to refer to the use of a computer program as part of the toolchain or operating system that produces new versions of that same program—for example, a compiler that can compile its own source code. Self-hosting software is commonplace on personal computers and larger...
- Self-interpreter
A self-interpreter, or metainterpreter, is a programming language interpreter written in the language it interprets. An example would be a BASIC interpreter written in BASIC...
External links