Home      Discussion      Topics      Dictionary      Almanac
Signup       Login
PyPy

PyPy

Overview
PyPy is a self-hosting
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...

  interpreter
Interpreter (computing)
In 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 language
Python (programming language)
Python 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 CPython
CPython
CPython 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.
Discussion
Ask a question about 'PyPy'
Start a new discussion about 'PyPy'
Answer questions from other users
Full Discussion Forum
 
Encyclopedia
PyPy is a self-hosting
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...

  interpreter
Interpreter (computing)
In 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 language
Python (programming language)
Python 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 CPython
CPython
CPython 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 evaluator
Meta-circular evaluator
A 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 subset
Subset
In 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 C
C (programming language)
C 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 bytecode
Java bytecode
Java 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 Language
Common Intermediate Language
Common 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 Psyco
Psyco
Psyco 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-time
Just-in-time compilation
In 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 compiler
Run-time algorithm specialisation
In 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, Pyglet
Pyglet
Pyglet is an OpenGL-based software library used in developing games and other visually-rich applications using the object-oriented language Python....

 and Divmod's Nevow
Nevow
Nevow 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 Union
European Union
The 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 STReP
STReP
Specific 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 Google
Google
Google 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 CPython
CPython
CPython 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 (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
    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
    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