PyPy implements the Python language version 2.7.3. It supports all of the core language, passing Python test suite (with minor modifications that were already accepted in the main python in newer versions). It supports most of the commonly used Python standard library modules; details below.
PyPy has alpha/beta-level support for the CPython C API, however, as of 2.2 release this feature is not yet complete. Many libraries will require a bit of effort to work, but there are known success stories. Check out PyPy blog for updates, as well as the Compatibility Wiki.
C extensions need to be recompiled for PyPy in order to work. Depending on your build system, it might work out of the box or will be slightly harder.
Standard library modules supported by PyPy. Note that large parts of python library are implemented in pure python, so they don't have to be listed there. Please just check if it imports. If it imports, it should work.
- __builtin__, __pypy__, _ast, _bisect, _codecs, _collections, _ffi, _hashlib, _io, _locale, _lsprof, _md5, _minimal_curses, _multiprocessing, _random, _rawffi, _sha, _socket, _sre, _ssl, _warnings, _weakref, _winreg, array, binascii, bz2, cStringIO, clr, cmath, cpyext, crypt, errno, exceptions, fcntl, gc, imp, itertools, marshal, math, mmap, operator, oracle, parser, posix, pyexpat, select, signal, struct, symbol, sys, termios, thread, time, token, unicodedata, zipimport, zlib
Supported, but written in pure-python:
- cPickle, _csv, ctypes, datetime, dbm, _functools, grp, pwd, readline, resource, sqlite3, syslog, tputil
All modules that are pure python in CPython of course work.
Python libraries known to work under PyPy (the list is not exhaustive). A community maintained compatibility wiki is hosted on bitbucket:
- twisted (without ssl support)
- divmod's nevow
Known differences that are not going to be fixed:
PyPy does not support refcounting semantics. The following code won't fill the file immediately, but only after a certain period of time, when the GC does a collection:
The proper fix is
f = open("filename", "w")
or using the with keyword
with open("filename", "w") as f:
See more details here.
For the same reason, some functions and attributes of the gc module behave in a slightly different way: for example, gc.enable and gc.disable are supported, but instead of enabling and disabling the GC, they just enable and disable the execution of finalizers. Also, gc.garbage always returns an empty list.
You can't add a __del__ method to an existing class; it must be present in the class since the beginning, or else it will not be automatically called when instances are freed.
You can't store non-string keys in type objects. Example
locals() = 3
A more complete list is available at our dev site.