| PyPy | |
|---|---|
| Initial release | mid 2007; 19 years ago (2007) |
| Stable release | |
| Written in | RPython |
| Operating system | Cross-platform |
| Type | Python interpreter and compilertoolchain |
| License | MIT |
| Website | pypy |
| Repository | |
PyPy (/ˈpaɪpaɪ/) is an implementation of thePythonprogramming language.[2] PyPy frequently runs much faster than the standardimplementationCPython because PyPy uses ajust-in-time compiler.[3] 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.
PyPy itself is built using a technique known asmeta-tracing, which is a mostly automatic transformation that takes aninterpreter as input and produces atracing just-in-time compiler as output. Since interpreters are usually easier to write thancompilers, but run slower, this technique can make it easier to produce efficient implementations of programming languages. PyPy's meta-tracingtoolchain is calledRPython.
PyPy officially supports Python 2.7 and 3.11[4] and has a few differences in implementations compared to CPython.[5]
PyPy aims to provide a common translation and support framework for producing implementations ofdynamic languages, emphasizing a clean separation betweenlanguage specification and implementation aspects. It also aims to provide a compliant, flexible and fast implementation of the Python programming language using the aboveframework to enable new advanced features without having to encode low-level details into it.[6][7]
The PyPy interpreter itself is written in a restricted subset of Python called RPython (Restricted Python).[8] RPython puts some constraints on the Python language such that a variable's type can beinferred at compile time.[9]
The PyPy project has developed atoolchain that analyzes RPython code and translates it into a form ofbyte code, which can be lowered intoC. There used to be otherbackends in addition toC (Java,C#, andJavaScript), but those suffered frombitrot and have been removed. Thus, therecursive logo of PyPy is asnake swallowing itself since the RPython is translated by a Pythoninterpreter. The code can also be run untranslated for testing and analysis, which provides a nicetest-bed for research into dynamic languages.
It allows for pluggablegarbage collectors, as well as optionally enablingStackless Python features. Finally, it includes a just-in-time (JIT)generator that builds ajust-in-time compiler into the interpreter, given a few annotations in theinterpretersource code. The generated JIT compiler is atracing JIT.[10]
RPython is now also used to write non-Python language implementations, such asPixie.[11]
PyPy as of version 7.3.17 is compatible with twoCPython versions: 2.7 and 3.10.[12][13] The first PyPy version compatible with CPython v3 is PyPy v2.3.1 (2014).[14] The PyPy interpreter compatible with CPython v3 is also known as PyPy3.
PyPy hasJIT compilation support on 32-bit/64-bitx86 and 32-bit/64-bitARM processors.[15] 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.[16]
There is a compatibility layer for CPython C API extensions called CPyExt, but it is incomplete and experimental. The preferred way of interfacing withCshared libraries is through the built-in Cforeign function interface (CFFI) orctypes libraries.
PyPy is a followup to thePsyco project, ajust-in-timespecializing 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 intoJava bytecode,CIL andJavaScript, 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 duringcoding sprints.
PyPy was funded by theEuropean Union being aSpecific Targeted Research Project[32] between December 2004 and March 2007. In June 2008, PyPy announced funding being part of theGoogle Open Source programs and has agreed to focus on making PyPy more compatible withCPython. In 2009 Eurostars, a European Union funding agency specially focused onSMEs,[33] accepted a proposal from PyPy project members titled "PYJIT – a fast and flexible toolkit for dynamic programming languages based on PyPy". Eurostars funding lasted until August 2011.[34]AtPyCon US 2011, thePython Software Foundation provided a $10,000 grant for PyPy to continue work on performance and compatibility with newer versions of the language.[35]The port to ARM architecture was sponsored in part by theRaspberry Pi Foundation.[23]
The PyPy project also accepts donations through its status blog pages.[36] As of 2013, a variety of sub-projects had funding: Python 3 version compatibility, built-in optimizedNumPy support for numerical calculations andsoftware transactional memory support to allow better parallelism.[23]