What Python Libraries and Code Does PyPy Support?

Updated

PyPy is designed as a drop-in replacement for CPython, so most pure-Python code runs unchanged. It supports Python 3.12, 3.11, and 2.7, and on average PyPy 3.12 runs about 4 times faster than CPython 3.11. The main compatibility question is not your own code but your dependencies: pure-Python libraries generally work, while libraries built on C extensions depend on whether they use a supported interface.

What "compatible" means in practice

PyPy is a compliant alternative implementation of Python. That means the language semantics, standard library, and typical application code behave as they do on CPython. If your project is written in plain Python and its dependencies are also pure Python, you can generally run it on PyPy without changes.

The friction point is C extensions. CPython's native extension API is not PyPy's native interface, so PyPy provides compatibility layers rather than running CPython C extensions directly.

Supported C-extension interfaces

PyPy explicitly supports these ways of reaching native code:

  • cffi — the recommended C foreign function interface, and the one PyPy's own documentation highlights.
  • cppyy — for C++ integration.
  • A C-extension compatibility layer — this is what lets PyPy run libraries such as NumPy and Scikit-learn, which are built on C extensions.

If a library offers a cffi or cppyy path, that is the most reliable route on PyPy. If it only ships a CPython-specific C extension, support depends on the compatibility layer and may be slower or incomplete.

Popular libraries confirmed to run

PyPy's own materials name several widely used libraries as runnable:

Library How it runs on PyPy
Twisted Supported
Django Supported
NumPy Via the C-extension compatibility layer
Scikit-learn Via the C-extension compatibility layer

This list is illustrative, not exhaustive. The pattern to apply: pure-Python frameworks like Django and Twisted work directly, while scientific and numeric libraries that rely on C extensions go through the compatibility layer.

How to decide whether your project will run

  1. Check your own code. If it is pure Python, it should run as-is.
  2. List your dependencies. Separate pure-Python packages from those with C extensions.
  3. For C-extension packages, look for cffi or cppyy support. Those are the interfaces PyPy names as supported.
  4. For packages like NumPy or Scikit-learn, expect the compatibility layer to handle it, and test your actual workload rather than assuming identical behavior.
  5. Run your test suite on PyPy. Compatibility is high but not identical, so your own tests are the real verification.

Where the payoff shows up

Two advantages matter when deciding:

  • Speed — the Just-In-Time compiler often makes Python programs run faster. The headline figure is about 4 times faster than CPython 3.11 on average, measured by PyPy's own benchmarks.
  • Memory — memory-hungry programs using several hundred MBs or more may take less space than on CPython.

There is also stackless mode, included by default, which provides micro-threads for massive concurrency.

A note from a real user

Miðeind's founder and CEO, Vilhjálmur Þorsteinsson, said in February 2022 that PyPy let the company use Python for a larger part of its toolset than CPython alone would have supported, and that its smooth integration with C/C++ through CFFI improved the tradeoff between performance and programmer productivity. That is a concrete example of the cffi path paying off in a production setting.

The short answer

Pure-Python code and pure-Python libraries run on PyPy with high compatibility. For native code, PyPy supports cffi and cppyy, and runs NumPy, Scikit-learn, and similar libraries through a C-extension compatibility layer. Twisted and Django are confirmed to run. The practical test is always your own dependency list plus your own test suite.