[pypy-dev] cpyext performance

Amaury Forgeot d'Arc amauryfa at gmail.com
Tue Jul 3 14:55:40 CEST 2012


Hi,

2012/7/3 Stefan Behnel <stefan_ml at behnel.de>

> I've been working with one of the modules in the Python benchmark suite,
> namely nbody, and tried to make it run a little faster when compiled with
> Cython in PyPy. I managed to get a massive speed-up by avoiding some
> borrowed references during list iteration and using PySequence_GetItem()
> instead, but now some 50-60% of the runtime are spent in Py_DecRef().
>

Don't forget that cpyext reference counts are quite different from CPython:
PySequence_GetItem() needs to *create* a PyObject structure, and the
returned object has a refcount of 1.
Then Py_DECREF() will really *deallocate* the PyObject structure...

This is quite more expensive than the simple refcount increment/decrement
done by CPython.


> OverflowError: array too large
>

Looks like a ctypes bug to me. Which OS, Python, etc. are you using?


-- 
Amaury Forgeot d'Arc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20120703/d436c80e/attachment.html>


More information about the pypy-dev mailing list