PyPy
Encyclopedia
PyPy is a Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

 interpreter and JIT compiler
Just-in-time compilation
In computing, just-in-time compilation , also known as dynamic translation, is a method to improve the runtime performance of computer programs. Historically, computer programs had two modes of runtime operation, either interpreted or static compilation...

. PyPy focuses on speed, efficiency and 100% compatibility with the original CPython interpreter.

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. The fact that PyPy is implemented in a high level language makes it 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. There...

, 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, emphasizing 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 implements 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. A and B may coincide. The relationship of one set being a subset of another is called inclusion or sometimes containment...

, 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 between 1969 and 1973 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. 51 are reserved for future use...

 or Common Intermediate Language
Common Intermediate Language
Common Intermediate Language is the lowest-level human-readable programming language defined by the Common Language Infrastructure specification and is used by the .NET Framework and Mono...

. It also allows for pluggable Garbage collectors
Garbage collection (computer science)
In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...

 as well as optionally enabling Stackless. Finally it includes a JIT generator which builds a just-in-time compiler into the interpreter, given a few annotations in the interpreter source code. The generated JIT compiler is a tracing JIT.

Project status

The latest PyPy release, PyPy 1.7, is CPython 2.7.1 compatible. It runs on 32- and 64-bit Intel x86 architecture and includes a JIT
Just-in-time compilation
In computing, just-in-time compilation , also known as dynamic translation, is a method to improve the runtime performance of computer programs. Historically, computer programs had two modes of runtime operation, either interpreted or static compilation...

 compiler. It's nightly tested on Windows, Linux and Mac OS X. PyPy is able to run pure Python software that does not rely on implementation-specific features. A translation for CPython C API extensions exists, but is incomplete and experimental. Interfacing with shared libraries is recommended via the ctypes infrastructure.

History

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 method to improve the runtime performance of computer programs. Historically, computer programs had two modes of runtime operation, either interpreted or static 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. Reaching a mature state of development and an official 1.0 release in mid-2007, its next focus was on releasing a production-ready version with more CPython compatibility. Version 1.1 was released on April 28, 2009. Many of PyPy's changes have been made during coding sprints.

As of late 2008, PyPy was 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....

, Nevow
Nevow
Nevow is a Python web application framework originally developed by the company Divmod. 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...

 and Django.

In March 2010, PyPy 1.2 was released, focusing on speed. It included a just-in-time compiler, which works, but was not advised to run in production environments. Along with the 1.2 release, the website was redesigned and a new PyPy speed center for tracking progress was brought up.

In December 2010, PyPy 1.4, the first PyPy suitable for production use was released. PyPy 1.4 is compatible
with Python 2.5.

On April 30, 2011, PyPy 1.5 was released. PyPy 1.5 is compatible with Python 2.7.1.

On August 18, 2011, PyPy 1.6 was released.

On November 21, 2011, PyPy 1.7 was released.

Funding

PyPy was funded by the European Union
European Union
The European Union is an economic and political union of 27 independent member states which are located primarily in Europe. The EU traces its origins from the European Coal and Steel Community and the European Economic Community , formed by six countries in 1958...

 as a STReP
Strep
Strep or STReP may refer to:*An abbreviation for Streptococcus, a bacterial genus*An abbreviation for Streptococcal pharyngitis, an infectious disease...

 between December 2004 and March 2007. In June 2008, PyPy announced funding as part of the Google
Google
Google Inc. is an American multinational public corporation invested in Internet search, cloud computing, and advertising technologies. Google hosts and develops a number of Internet-based services and products, and generates profit primarily from advertising through its AdWords program...

 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. There...

. In 2009 Eurostars, a European Union funding agency specially focused on SMEs, accepted a proposal from
PyPy project members entitled: "PYJIT - a fast and flexible toolkit for dynamic programming languages based on PyPy". Eurostars funding will last until August 2011.
At PyCon US 2011, the Python Software Foundation
Python Software Foundation
The Python Software Foundation , is a non-profit organization devoted to the Python programming language, launched on March 6, 2001. The mission of the foundation is to foster development of the Python community and is responsible for various processes within the Python community, including...

 provided a $10,000 grant for PyPy to continue work on performance and compatibility with newer versions of the language.
The PyPy project also accepts donations through its status blog pages.

Supported backends

  • C - the RPython code can be translated to C and run as a native program, and this is the standard operation mode;
  • CLI
    Common Language Infrastructure
    The Common Language Infrastructure is an open specification developed by Microsoft and standardized by ISO and ECMA that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework and the free and open source implementations Mono and Portable.NET...

     - Common Language Interface;
  • JVM - Java Virtual Machine;
  • Python (programming language)
    Python (programming language)
    Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

     - the PyPy interpreter can also be run on a Python interpreter. Though extremely slow, this possibility is useful for debugging.


As of 2010, PyPy has abandoned its JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

 backend.

See also

  • Bootstrapping (compilers)
    Bootstrapping (compilers)
    In computer science, bootstrapping is the process of 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...

  • 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....

  • Rubinius
    Rubinius
    Rubinius is an alternative Ruby programming language implementation created by Evan Phoenix. Based loosely on the Smalltalk-80 Blue Book design, Rubinius seeks to"provide a rich, high-performance environment for running Ruby code."-Goals:...

    Ruby implementation in Ruby

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK