Trisha Shetty (Editor)

PyPy

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Written in
  
RPython

Operating system
  
Cross-platform

PyPy

Initial release
  
mid 2007; 10 years ago (2007)

Stable release
  
5.6.0 / 12 November 2016; 4 months ago (2016-11-12)

Repository
  
bitbucket.org/pypy/pypy

Type
  
Python interpreter and compiler toolchain

PyPy is an alternate implementation of the Python programming language written in Python. To be specific, the Interpreter is written in RPython (a subset of Python). In contrast, the standard reference implementation of Python is written in C (known as CPython). The implementation of the interpreter in high level Python, over a low-level implementation in C, enables quick experimentation of new language features. This is shown to have benefits in areas of execution speed, memory usage, sandboxing etc, in certain use cases.

Contents

Details and motivation

PyPy was conceived to be an implementation of Python written in a programming language that is similar to Python. This makes it easy to identify areas where it can be improved and makes PyPy more flexible and easier to experiment with than CPython.

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.

RPython

The PyPy interpreter itself is written in a restricted subset of Python, called RPython (Restricted Python). The self-hosting nature of PyPy is reflected in the project's logo, which depicts a snake swallowing its own tail in an ouroboros. RPython puts some constraints on the Python language such that a variable's type can be inferred at compile time.

The PyPy project has developed a toolchain that analyzes RPython code and translates it into C code, which is then compiled to produce a native interpreter. It also allows for pluggable garbage collectors as well as optionally enabling Stackless Python features. Finally, it includes a just-in-time (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.

RPython is now also used to write non-Python language implementation such as Pixie.

Project status

PyPy is CPython 2.7.10 compatible. PyPy3, released starting with version 2.3.1, is CPython 3.2.5 compatible. Both versions have JIT compilation support on 32-bit/64-bit x86 and ARM processors. It is tested nightly on Windows, Linux, OpenBSD and Mac OS X. PyPy is able to run pure Python software that does not rely on implementation-specific features.

There is a compatibility layer for CPython C API extensions called CPyExt, but it is incomplete and experimental. The preferred way of interfacing with C shared libraries is through the built-in CFFI or ctypes libraries.

History

PyPy is a followup to the Psyco project, a just-in-time specializing compiler for Python, developed by Armin Rigo between 2002 and 2010. PyPy's aim is to have a just-in-time specializing compiler with scope, which was not available for Psyco. Initially, the RPython could also be compiled into Java bytecode, CIL and JavaScript, but these backends were removed due to lack of interest.

PyPy was initially 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. 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, Nevow and Django.

In March 2010, PyPy 1.2 was released, focusing on speed. It included a working, though not yet stable, just-in-time compiler.

In April 2011, PyPy version 1.5 was released, which reached compatibility with CPython 2.7.

On May 9, 2013, PyPy 2.0 was released, which introduced alpha-quality support for JIT compilation on ARMv6 and ARMv7 JIT, and included CFFI in the standard library.

On June 20, 2014, PyPy3 was declared stable and introduced compatibility with the more modern Python 3. It was released alongside PyPy 2.3.1 and bears the same version number.

Funding

PyPy was funded by the European Union being a Specific Targeted Research Project between December 2004 and March 2007. In June 2008, PyPy announced funding being part of the Google Open Source programs, and has agreed to focus on making PyPy more compatible with CPython. 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 lasted until August 2011. At PyCon US 2011, the Python Software Foundation provided a $10,000 grant for PyPy to continue work on performance and compatibility with newer versions of the language. The port to ARM architecture was sponsored in part by the Raspberry Pi Foundation.

The PyPy project also accepts donations through its status blog pages. There are three funding projects currently in progress: Python 3 version compatibility, built-in optimized NumPy support for numerical calculations and software transactional memory support to allow better parallelism.

References

PyPy Wikipedia