Python compatibility
PyPy implements Python language version 2.5. It supports all of the core language, passing Python test suite (with minor modifications that were already accepted in main python in newer versions). It supports most of commonly used Python standard library modules, list below.
PyPy does not support CPython C API, which means that third party libraries for python, written in C, will not work.
Standard library modules supported by PyPy, in alphabetical order:
- __builtin__ __pypy__ _codecs _lsprof _minimal_curses _random _rawffi _socket _sre _weakref bz2 cStringIO crypt errno exceptions fcntl gc itertools marshal math md5 mmap operator parser posix pyexpat select sha signal struct symbol sys termios thread time token unicodedata zipimport zlib
Supported, but written in pure-python:
- array binascii cPickle cmath collections ctypes datetime functools grp md5 pwd pyexpat sha sqlite3 syslog
All modules that are pure python in CPython of course work.
Python libraries known to work under PyPy (the list is not exhaustive):
- ctypes
- django (without any DB but sqlite)
- twisted (without ssl support)
- pylons
- divmod's nevow
- pyglet
Known differencies that are not going to be fixed:
PyPy does not support refcounting semantics. The code below won't fill the file immediately, but only after a certain period of time, when the GC will collect:
open("filename", "w").write("stuff")
The proper fix is:
f = open("filename", "w") f.write("stuff") f.close()
We don't support certain attributes that were decided to be implementation-dependent. For example gc.get_referrers. gc.enable and gc.disable are supported, but they don't enable and disable GC, but instead enable and disable running of finalizers.
You can't attach a __del__ method to a class after its creation.
You can't store non-string keys in type objects. Example:
class A(object): locals()[42] = 3
won't work.