PyPy
Stable release | 2.4.0
/ 22 September 2014 |
---|---|
Repository | |
Written in | RPython |
Operating system | Cross-platform |
Type | Python interpreter and compiler toolchain |
License | MIT License |
Website | pypy |
PyPy is a Python interpreter and just-in-time compiler. PyPy focuses on speed, efficiency and compatibility with the original CPython interpreter.[1]
PyPy started out as a Python interpreter written in the Python language itself. Current PyPy versions are translated from RPython to C code and compiled. The PyPy JIT (short for "Just In Time") compiler is capable of turning Python code into machine code at run time.
Details and motivation
PyPy was conceived as 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.[citation needed]
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.[1][2]
RPython
The PyPy interpreter itself is written in a restricted subset of Python, called RPython (Restricted Python).[3] RPython puts some constraints on the Python language so that a variable's type can be inferred at compile time.[4]
The PyPy project has developed a tool chain 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.[5]
Project status
The latest stable PyPy release, PyPy 2.3.1, is CPython 2.7.6 compatible and for the first time, PyPy3 was released as stable too with the same version number and is CPython 3.2.5 compatible.[6] Both versions have JIT compilation support on 32-bit/64-bit x86 and ARM processors.[7] It's 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.[8]
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.[clarification needed] Initially, the RPython could also be compiled into Java bytecode, CIL and JavaScript, but these backends were removed due to lack of interest.
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. 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,[9] Pyglet,[10] Nevow[11] and Django.[12]
In March 2010, PyPy 1.2 was released, focusing on speed. It included a working just-in-time compiler, but was not advised to be 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.[13]
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.[7]
On June 20, 2014, PyPy3 is declared stable [6] and brings compatibility with more modern implementations of the Python language. It is released alongside PyPy 2.3.1 and bears the same version number.
Funding
PyPy was funded by the European Union as a Specific Targeted Research Project[14] between December 2004 and March 2007. In June 2008, PyPy announced funding as 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,[15] 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.[16] 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.[17] The port to ARM architecture was sponsored in part by the Raspberry Pi Foundation.[7]
The PyPy project also accepts donations through its status blog pages.[18] 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.[7]
Projects using PyPy's toolchain
- Topaz- an implementation of the Ruby programming language
- HippyVM - an implementation of the PHP language using PyPy technology.
See also
- Bootstrapping (compilers)
- Partial evaluation#Futamura projections[19]
- Cython
- Psyco
- Self-hosting
- Self-interpreter
- Rubinius (Ruby implementation in Ruby)
- Jikes RVM (Java implementation in Java)
Notes
- ^ a b Samuele Pedroni (March 2007). "PyPy - Goals and Architecture Overview".
- ^ "PyPy - Goals and Architecture Overview - Mission Statement". Retrieved 11 October 2013.
- ^ http://doc.pypy.org/en/latest/coding-guide.html#id1
- ^ "It is a proper subset of Python, restricted in a way that enables easy analysis and efficient code generation", Ancona et al., 2007.
- ^ Bolz et al., 2009
- ^ a b the PyPy team (20 June 2014). "PyPy3 2.3.1 - Fulcrum". PyPy blog.
- ^ a b c d Jake Edge (15 May 2013). "A look at the PyPy 2.0 release". LWN.net.
- ^ "PyPy - Python compatibility".
- ^ "Running pylons on top of PyPy".
- ^ "Running Pyglet on top of PyPy".
- ^ "Running Nevow on top of PyPy".
- ^ "PyPy runs unmodified django 1.0 beta".
- ^ Corbet, Jonathan (19 May 2012). "PyPy: the other new compiler project". LWN.net.
- ^ "EU Community Research and Development Information Service Entry".
- ^ "Eurostars - Aim Higher".
- ^ "Project Page on Eureka Network".
- ^ "A thank you to the PSF".
- ^ "PyPy Status Blog: Oh, and btw: PyPy gets funding through "Eurostars"".
- ^ tomykaira (July 2012). "Partial Evaluation, Futamura Projection And Their Applications".
References
- Davide Ancona, Massimo Ancona, Antonio Cuni, Nicholas D. Matsakis, 2007. RPython: a Step Towards Reconciling Dynamically and Statically Typed OO Languages. In Proc. Dynamic Language Symposium (DLS), 2007. ACM Press.
- Carl Friedrich Bolz, Antonio Cuni, Maciej Fijalkowski, 2009. Tracing the meta-level: PyPy's Tracing JIT Compiler. In Proc. ICOOOLPS, 2009. ACM Press.
- Corbet, Jonathan (May 11, 2011). "A brief experiment with PyPy". LWN.net.
- von Eitzen, Chris (November 21, 2011). "PyPy 1.7 widens the performance "sweet spot"". The H. Heinz Heise.
- Rose, John (December 2, 2011). "A Day with PyPy". Oracle developer blog.
External links
- Official website
- Official status blog
- PyPy nightly benchmark run
- Python in Python: The PyPy System - technical talk by the designer of PyPy (video archive)