What Are the Advantages and Distinct Features of PyPy?

Updated

PyPy is a fast, compliant alternative implementation of Python. Its main advantages over CPython are speed from a Just-in-Time (JIT) compiler, potentially lower memory usage for memory-hungry programs, built-in stackless mode for massive concurrency, and strong compatibility with existing Python code and libraries. According to the PyPy project, PyPy 3.12 is on average about 4 times faster than CPython 3.11, and it currently supports Python 3.12, 3.11, and 2.7.

Speed: JIT compilation

PyPy's headline feature is its Just-In-Time compiler. Instead of interpreting Python code line by line like CPython, PyPy compiles frequently executed code paths into machine code at runtime, so Python programs often run faster.

The project publishes live benchmark data at speed.pypy.org, where PyPy (with JIT) benchmark times are normalized to CPython — smaller is better. The site states that on average PyPy 3.12 is about 4 times faster than CPython 3.11.

This matters most for long-running, CPU-bound workloads where the JIT has time to warm up. Short scripts that start and exit quickly may see little or no benefit, since the JIT never gets a chance to optimize hot code.

Memory usage

PyPy can also reduce memory consumption. According to the project, memory-hungry Python programs — those using several hundreds of MBs or more — might end up taking less space than they do in CPython.

This is not a universal guarantee: memory behavior depends on the workload, and some programs may use more memory under PyPy. The advantage is most likely to appear in larger, allocation-heavy applications.

Stackless mode and micro-threads

PyPy comes by default with support for stackless mode, which provides micro-threads for massive concurrency. This is built in rather than requiring a separate interpreter build, so concurrency-heavy code can be written without relying on OS threads alone.

Compatibility with existing code and libraries

PyPy is described as highly compatible with existing Python code. It supports:

  • cffi and cppyy for interfacing with C and C++ code
  • Popular libraries such as twisted and django
  • NumPy, Scikit-learn, and more via a C-extension compatibility layer

This compatibility is what lets teams adopt PyPy without rewriting their codebase. As Vilhjálmur Þorsteinsson, founder and CEO of Miðeind, put it in February 2022: PyPy "has enabled us to use Python for a larger part of our toolset than CPython alone would have supported," and its integration with C/C++ through CFFI helped balance performance and programmer productivity.

When PyPy is a good fit

Situation PyPy likely helps
Long-running, CPU-bound Python programs Yes — JIT optimizes hot code
Programs using hundreds of MBs or more Possibly — memory may be lower than CPython
Code needing massive concurrency Yes — stackless micro-threads are built in
Code using cffi, cppyy, twisted, django, NumPy, Scikit-learn Yes — supported via compatibility layers
Very short scripts that exit quickly Limited — JIT has no time to warm up

To evaluate it for your own workload, download PyPy from pypy.org, run your program under it, and compare runtime and memory against CPython. The project's live benchmark data at speed.pypy.org gives a general reference, but your specific code is the deciding factor.