|Initial release||mid 2007|
7.1 / 24 March 2019
|Type||Python interpreter and compiler toolchain|
PyPy is an alternative implementation of the Python programming language to CPython, which is the standard implementation of Python. PyPy often runs faster than CPython, because PyPy is a just-in-time compiler, while CPython is an interpreter. Most Python code runs well on PyPy, except for code that depends on CPython extensions, which either does not work or incurs some overhead when run in PyPy. Functionally, PyPy is designed around the technique known as meta-tracing, which transforms an interpreter into a tracing just-in-time compiler. Since interpreters are usually easier to write than compilers, but run slower, this technique can make it easier to produce efficient implementations of programming languages. PyPy's meta-tracing toolchain is called RPython.
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.
The PyPy interpreter itself is written in a restricted subset of Python called RPython (Restricted Python). 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 a form of byte code, together with an interpreter written in the C programming language. Much of this code is then compiled into machine code, and the byte code runs on the compiled interpreter.
It allows for pluggable garbage collectors, as well as optionally enabling Stackless Python features. Finally, it includes a just-in-time (JIT) generator that 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.
PyPy is compatible with CPython 2.7.13. PyPy3, released starting with version 2.3.1, is compatible with CPython 3.5.3. 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.
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.
- In August 2008, PyPy was able to run some popular Python libraries like Pylons, Pyglet, Nevow and Django.
- On 12 March 2010, PyPy 1.2 was released, focusing on speed. It included a working, though not yet stable, just-in-time compiler.
- On 30 April 2011, PyPy version 1.5 was released, which reached compatibility with CPython 2.7.
- On 9 May 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 20 June 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.
- On 21 March 2017, the PyPy project released version 5.7 of both PyPy and PyPy3, with the latter introducing beta-quality support for Python 3.5.
- On 26 April 2018, version 6.0 was released.
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.
- Bootstrapping (compilers)
- Partial evaluation
- Unladen Swallow
- "PyPy Status Blog". Retrieved 24 March 2019 – via BlogSpot.
- "Interview Maciej Fijalkowski PyPy".
- Samuele Pedroni (March 2007). "PyPy – Goals and Architecture Overview". Archived from the original on 2012-06-30.
- "PyPy – Goals and Architecture Overview – Mission Statement". Retrieved 11 October 2013.
- Our runtime interpreter is “RPython”, Coding Guide – PyPy documentation
- "It is a proper subset of Python, restricted in a way that enables easy analysis and efficient code generation", Ancona et al., 2007.
- Bolz, Carl; Cuni, Antonio; Fijalkowski, Maciej; Rigo, Armin. Tracing the Meta-Level: PyPy’s Tracing JIT Compiler. ICOOOLPS '09. doi:10.1145/1565824.1565827.
- Timothy Balridge interview.
- "PyPy – Python compatibility". pypy.org. Retrieved 2016-04-21.
- the PyPy team (20 June 2014). "PyPy3 2.3.1 – Fulcrum". PyPy blog.
- 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".
- "Introducing the PyPy 1.2 release".
- "PyPy 1.5 Released: Catching Up".
- "PyPy 2.0 – Einstein Sandwich".
- "PyPy2.7 and PyPy3.5 v5.7 – two in one release".
- "PyPy2.7 and PyPy3.5 v6.0 dual release".
- "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"".
- 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 (11 May 2011). "A brief experiment with PyPy". LWN.net.
- von Eitzen, Chris (21 November 2011). "PyPy 1.7 widens the performance "sweet spot"". The H. Heinz Heise.
- Rose, John (2 December 2011). "A Day with PyPy". Oracle developer blog.
- "Interview Maciej Fijalkowski pypy". Decisionstats blog.