Thursday, November 22, 2012

PyPy 2.0 beta 1

We're pleased to announce the 2.0 beta 1 release of PyPy. This release is not a typical beta, in a sense the stability is the same or better than 1.9 and can be used in production. It does however include a few performance regressions documented below that don't allow us to label is as 2.0 final. (It also contains many performance improvements.)

The main features of this release are support for ARM processor and compatibility with CFFI. It also includes numerous improvements to the numpy in pypy effort, cpyext and performance.

You can download the PyPy 2.0 beta 1 release here:

http://pypy.org/download.html

What is PyPy?

PyPy is a very compliant Python interpreter, almost a drop-in replacement for CPython 2.7.3. It's fast (pypy 2.0 beta 1 and cpython 2.7.3 performance comparison) due to its integrated tracing JIT compiler.

This release supports x86 machines running Linux 32/64, Mac OS X 64 or Windows 32. It also supports ARM machines running Linux. Windows 64 work is still stalling, we would welcome a volunteer to handle that.

How to use PyPy?

We suggest using PyPy from a virtualenv. Once you have a virtualenv installed, you can follow instructions from pypy documentation on how to proceed. This document also covers other installation schemes.

Regressions

Reasons why this is not PyPy 2.0:

  • the ctypes fast path is now slower than it used to be. In PyPy 1.9 ctypes was either incredibly faster or slower than CPython depending whether you hit the fast path or not. Right now it's usually simply slower. We're probably going to rewrite ctypes using cffi, which will make it universally faster.
  • cffi (an alternative to interfacing with C code) is very fast, but it is missing one optimization that will make it as fast as a native call from C.
  • numpypy lazy computation was disabled for the sake of simplicity. We should reenable this for the final 2.0 release.

Highlights

  • cffi is officially supported by PyPy. You can install it normally by using pip install cffi once you have installed PyPy and pip. The corresponding 0.4 version of cffi has been released.
  • ARM is now an officially supported processor architecture. PyPy now work on soft-float ARM/Linux builds. Currently ARM processors supporting the ARMv7 and later ISA that include a floating-point unit are supported.
  • This release contains the latest Python standard library 2.7.3 and is fully compatible with Python 2.7.3.
  • It does not however contain hash randomization, since the solution present in CPython is not solving the problem anyway. The reason can be found on the CPython issue tracker.
  • gc.get_referrers() is now faster.
  • Various numpy improvements. The list includes:
    • axis argument support in many places
    • full support for fancy indexing
    • complex128 and complex64 dtypes
  • JIT hooks are now a powerful tool to introspect the JITting process that PyPy performs.
  • **kwds usage is much faster in the typical scenario
  • operations on long objects are now as fast as in CPython (from roughly 2x slower)
  • We now have special strategies for dict/set/list which contain unicode strings, which means that now such collections will be both faster and more compact.

Things we're working on

There are a few things that did not make it to the 2.0 beta 1, which are being actively worked on. Greenlets support in the JIT is one that we would like to have before 2.0 final. Two important items that will not make it to 2.0, but are being actively worked on, are:

  • Faster JIT warmup time.
  • Software Transactional Memory.

Cheers,
Maciej Fijalkowski, Armin Rigo and the PyPy team


9 comments:

Anonymous said...

Good job! 2 things:
1) the link to the .tar.bz for Linux 64 (libc 2.13) links to a corrupted file (bz2 claims it is corrupted, and its MD5 hash doesn't match the one on the page)

2) the link to the benchmark on this page: http://speed.pypy.org/comparison/?exe=1%2B785,2%2B472&ben=1,34,27,2,25,3,46,4,5,41,42,22,44,6,39,7,8,45,23,24,9,10,11,12,13,40,14,15,35,36,37,38,16,28,30,32,29,33,17,18,19,20,43&env=1,2&hor=true&bas=2%2B472&chart=normal+bars

is empty -- no charts were plotted. (I've turned off all my adblocking).

Anonymous said...

Oops, the chart appears now -- it took a long time to load.

Unknown said...

The OSX binary segfaults on a Lion 64bit. I tried both 2.0-beta1 and a nightly build. Notice, 1.9 works perfectly.

Unknown said...

I would be more than happy to give it a shot if there was solid PostgreSQL support - otherwise it is a no-go for me.

Anonymous said...

Issue 1257 still not fixed (memory leak when using web.py framework).

Anonymous said...

For PostgreSQL it works with psycopg2ct.

Gabriel said...

Just announced on the IRC channel: psycopg2cffi. They ported it for speed, but from my CFFI experience, I think the biggest advantage is maintainability.

Anonymous said...

I think I should give a try to this.
Goona give a shot
---------------
www.insecuregeek.blogspot.com

Unknown said...

If we can get greenlet support in the JIT that'd be fantastic - my non-blocking driver for MongoDB, Motor, will need it before it's usable with PyPy. Thanks for the amazing work!