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.
RPython is now also used to write non-Python language implementations such as