[pypy-dev] could it be that cpyext is faster than python + cffi?

Matti Picus matti.picus at gmail.com
Fri Feb 13 14:46:41 CET 2015


I am close to releasing a blog post about numpy.linalg

https://gist.github.com/mattip/25680e68fe7e2856fe0c

Note the benchmark section, this is not a typo. Here's how I got to the 
conclusion that cpyext is faster than python+cffi.

I installed numpy from the pypy/numpy repo on a nightly after 2.5.0

pip install git+https://bitbucket.org/pypy/numpy.git

I then benchmarked the two pypy methods of calling numpy.linalg.inv() 
via this script which simply calls linalg.inv() for different sized ndarray.

https://gist.github.com/mattip/a7b22dc237fb09a46758

$pypy inverse.py 10
UserWarning: npy_clear_floatstatus, npy_set_floatstatus_invalid not found
   warn('npy_clear_floatstatus, npy_set_floatstatus_invalid not found')
after   999999, for n= 10, time=20.64,     20.64 msec/1000 loops

and

$USE_CPYEXT=yes pypy inverse.py 10
after   999999, for n= 10, time= 8.52,      8.52 msec/1000 loops

Any thoughts? Comments on the blog post?
Matti



More information about the pypy-dev mailing list