HOME

TheInfoList



OR:

PyPy () is an implementation of the
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
programming language. PyPy often runs faster than the standard implementation
CPython CPython is the reference implementation of the Python programming language. Written in C and Python, CPython is the default and most widely used implementation of the Python language. CPython can be defined as both an interpreter and a compi ...
because PyPy uses a
just-in-time compiler In computing, just-in-time (JIT) compilation (also dynamic translation or run-time compilations) is a way of executing computer code that involves compilation during execution of a program (at run time) rather than before execution. This may cons ...
. 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. Internally, PyPy uses a 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 PyPy () is an implementation of the Python programming language. PyPy often runs faster than the standard implementation CPython because PyPy uses a just-in-time compiler. Most Python code runs well on PyPy except for code that depends on CPyth ...
. PyPy does not have full compatibility with more recent versions of the CPython ecosystem. While it claims compatibility with Python 2.7, 3.7, 3.8 and 3.9 ("a drop-in replacement for CPython"), it loses out on newer features and syntax in Python 3.10, such as syntax for
pattern matching In computer science, pattern matching is the act of checking a given sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern recognition, the match usually has to be exact: "either it will or will not be ...
.


Details and motivation

PyPy aims to provide a common translation and support framework for producing implementations of
dynamic language In computer science, a dynamic programming language is a class of high-level programming languages, which at runtime execute many common programming behaviours that static programming languages perform during compilation. These behaviors cou ...
s, 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). RPython puts some constraints on the Python language such that a variable's type can be
inferred Inferences are steps in reasoning, moving from premises to logical consequences; etymologically, the word '' infer'' means to "carry forward". Inference is theoretically traditionally divided into deduction and induction, a distinction that i ...
at compile time. The PyPy project has developed a
toolchain In software, a toolchain is a set of programming tools that is used to perform a complex software development task or to create a software product, which is typically another computer program or a set of related programs. In general, the tools for ...
that analyzes RPython code and translates it into a form of byte code, which can be lowered into C. There used to be other backends in addition to C: Java, C#, and Javascript, but those suffered from bitrot and have been removed. Thus, the recursive logo of PyPy is a snake swallowing itself since the RPython is translated by a Python interpreter. The code can also be run untranslated for testing and analysis, which provides a nice test-bed for research into dynamic languages. It allows for pluggable garbage collectors, as well as optionally enabling
Stackless Python Stackless Python, or Stackless, is a Python programming language interpreter, so named because it avoids depending on the C call stack for its own stack. In practice, Stackless Python uses the C stack, but the stack is cleared between function c ...
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 Tracing just-in-time compilation is a technique used by virtual machines to optimize the execution of a program at runtime. This is done by recording a linear sequence of frequently executed operations, compiling them to native machine code and ...
. RPython is now also used to write non-Python language implementations, such as
Pixie A pixie (also pisky, pixy, pixi, pizkie, and piskie in Cornwall and Devon, and pigsie or puggsy in the New Forest) is a mythical creature of British folklore. Pixies are considered to be particularly concentrated in the high moorland areas arou ...
.


Project status

PyPy as of version 7.3.7 is compatible with three
CPython CPython is the reference implementation of the Python programming language. Written in C and Python, CPython is the default and most widely used implementation of the Python language. CPython can be defined as both an interpreter and a compi ...
versions: 2.7, 3.7 and 3.8. The first PyPy version compatible with CPython v3 is PyPy v2.3.1 (2014). The PyPy interpreter compatible with CPython v3 is also known as PyPy3. PyPy has JIT compilation support on 32-bit/64-bit
x86 x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel based on the Intel 8086 microprocessor and its 8088 variant. The 8086 was introd ...
and 32-bit/64-bit
ARM In human anatomy, the arm refers to the upper limb in common usage, although academically the term specifically means the upper arm between the glenohumeral joint (shoulder joint) and the elbow joint. The distal part of the upper limb between th ...
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 In computer science, a library is a collection of non-volatile resources used by computer programs, often for software development. These may include configuration data, documentation, help data, message templates, pre-written code and su ...
is through the built-in C
foreign function interface A foreign function interface (FFI) is a mechanism by which a program written in one programming language can call routines or make use of services written in another. Naming The term comes from the specification for Common Lisp, which explicit ...
(CFFI) or ctypes libraries.


History

PyPy is a followup to the
Psyco Psyco is an unmaintained specializing just-in-time compiler for pre-2.7 Python originally developed by Armin Rigo and further maintained and developed by Christian Tismer. Development ceased in December, 2011. Psyco ran on BSD-derived opera ...
project, a just-in-time
specializing compiler In computer science, run-time algorithm specialization is a methodology for creating efficient algorithms for costly computation tasks of certain kinds. The methodology originates in the field of automated theorem proving and, more specifically, in ...
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 In computing, Java bytecode is the bytecode-structured instruction set of the Java virtual machine (JVM), a virtual machine that enables a computer to run programs written in the Java programming language and several other programming langua ...
, CIL and
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
, 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 sprint A hackathon (also known as a hack day, hackfest, datathon or codefest; a portmanteau of hacking and marathon) is an event where people engage in rapid and collaborative engineering over a relatively short period of time such as 24 or 48 hours. Th ...
s. * In August 2008, PyPy was able to run some popular Python libraries like
Pylons Pylon may refer to: Structures and boundaries * Pylon (architecture), the gateway to the inner part of an Ancient Egyptian temple or Christian cathedral * Pylon, a support tower structure for suspension bridges or highways * Pylon, an orange mar ...
,
Pyglet pyglet is a library for the Python programming language that provides an object-oriented application programming interface for the creation of games and other multimedia applications. pyglet runs on Microsoft Windows, macOS, and Linux; it is relea ...
,
Nevow Nevow (pronounced like the French ''nouveau'') 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 templa ...
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, with support for Python 2.7 and 3.5 (still beta-quality on Windows). * On 11 February 2019, version 7.0 was released, with support for Python 2.7 and 3.5. * On 14 October 2019, version 7.2 was released, with support for Python 3.6.9. * On 24 December 2019, version 7.3 was released, with support for Python 3.6.9. * On 16 February 2020, the PyPy team announced the move of the source code hosting from
Bitbucket Bitbucket is a Git-based source code repository hosting service owned by Atlassian. Bitbucket offers both commercial plans and free accounts with an unlimited number of private repositories. Services Bitbucket Cloud Bitbucket Cloud (previ ...
to heptapod.net with the repositories of the CFFI (C
Foreign Function Interface A foreign function interface (FFI) is a mechanism by which a program written in one programming language can call routines or make use of services written in another. Naming The term comes from the specification for Common Lisp, which explicit ...
) project. A new logo and website design are also published. However, the author and the license of the new logo are unknown.


Funding

PyPy was funded by the
European Union The European Union (EU) is a supranational political and economic union of member states that are located primarily in Europe. The union has a total area of and an estimated total population of about 447million. The EU has often been des ...
being a Specific Targeted Research Project between December 2004 and March 2007. In June 2008, PyPy announced funding being part of the
Google Google LLC () is an American multinational technology company focusing on search engine technology, online advertising, cloud computing, computer software, quantum computing, e-commerce, artificial intelligence, and consumer electronics. ...
Open Source programs and has agreed to focus on making PyPy more compatible with
CPython CPython is the reference implementation of the Python programming language. Written in C and Python, CPython is the default and most widely used implementation of the Python language. CPython can be defined as both an interpreter and a compi ...
. In 2009 Eurostars, a European Union funding agency specially focused on
SMEs Superconducting magnetic energy storage (SMES) systems store energy in the magnetic field created by the flow of direct current in a Superconductivity, superconducting coil which has been Cryogenics, cryogenically cooled to a temperature below ...
, 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. At
PyCon The Python Conference (also called PyCon) is the largestpage 10 annual convention for the discussion and promotion of the Python programming language. It originated in the United States but is also held in more than 40 other countries. It was one ...
US 2011, the
Python Software Foundation The Python Software Foundation (PSF) is an American nonprofit 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 ...
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 Raspberry Pi Foundation is a British charity and company founded in 2009 to promote the study of basic computer science in schools, and is responsible for developing the Raspberry Pi single-board computers. Foundation The Raspberry Pi Foun ...
. The PyPy project also accepts donations through its status blog pages. As of 2013, a variety of sub-projects had funding: Python 3 version compatibility, built-in optimized NumPy support for numerical calculations and
software transactional memory In computer science, software transactional memory (STM) is a concurrency control mechanism analogous to database transactions for controlling access to shared memory in concurrent computing. It is an alternative to lock-based synchronization. STM ...
support to allow better parallelism.


See also

* Bootstrapping (compilers) *
Cython Cython () is a programming language that aims to be a superset of the Python programming language, designed to give C-like performance with code that is written mostly in Python with optional additional C-inspired syntax. Cython is a compiled ...
*
GraalVM GraalVM is a Java VM and JDK based on HotSpot/OpenJDK, implemented in Java. It supports additional programming languages and execution modes, like ahead-of-time compilation of Java applications for fast startup and low memory footprint. The fi ...
*
Partial evaluation In computing, partial evaluation is a technique for several different types of program optimization by specialization. The most straightforward application is to produce new programs that run faster than the originals while being guaranteed to ...
*
Psyco Psyco is an unmaintained specializing just-in-time compiler for pre-2.7 Python originally developed by Armin Rigo and further maintained and developed by Christian Tismer. Development ceased in December, 2011. Psyco ran on BSD-derived opera ...
* Self-hosting *
Self-interpreter In computer science, an interpreter is a computer program that directly execution (computers), executes instructions written in a Programming language, programming or scripting language, without requiring them previously to have been Compiler, co ...
*
Unladen Swallow CPython is the reference implementation of the Python programming language. Written in C and Python, CPython is the default and most widely used implementation of the Python language. CPython can be defined as both an interpreter and a compi ...


Notes


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


External links

* {{Python (programming language) 2007 software FP6 projects Free software programmed in Python Python (programming language) implementations * Software using the MIT license Stack-based virtual machines