Lably
Skip to content

PyPy

Alternative implementation of the Python programming language

  • 5 min read
  • 3 chapters

Related on Lably

Through Python (programming language), Implementation and Interpreter (computing)

PyPy itself is built using a technique known as meta-tracing, which is a mostly automatic transformation that takes an interpreter as input and produces a tracing just-in-time compiler as output. 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 officially supports Python 3.12, 3.11 and 2.7 and has a few differences in implementations compared to CPython.

Details and motivation

PyPy aims to provide a common translation and support framework for producing implementations of dynamic languages, emphasizing a separation between language specification and implementation aspects. It also aims to provide a compliant implementation of the Python programming language using the above framework enabling 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 at compile time.

The PyPy project has developed a toolchain 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 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.

RPython has also been used to write non-Python language implementations, such as a Lisp-based language called Pixie.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication

Source and licence. Adapted from the Wikipedia article “PyPy” (this version, 2026-10-02) by its contributors, shared under CC BY-SA 4.0. Lablypedia has left out its tables, references and most pictures, and linked it to other Lablypedia articles.