[pypy-issue] [issue1121] [cpyext] speed up some macros
Stefan Behnel
tracker at bugs.pypy.org
Fri Apr 20 21:34:47 CEST 2012
Stefan Behnel <stefan_ml at behnel.de> added the comment:
For the ref-counting macros, here is a "stupid micro benchmark" in Cython:
def bench(x):
cdef int i
for i in xrange(10000):
a = x
b = x
c = x
d = x
e = x
f = x
g = x
When always calling into Py_IncRef() and Py_DecRef(), I get this
$ pypy -m timeit -s 'from refcountbench import bench' 'bench(10)'
1000 loops, best of 3: 683 usec per loop
With the new macros for Py_INCREF() and Py_DECREF(), I get this:
$ pypy -m timeit -s 'from refcountbench import bench' 'bench(10)'
1000 loops, best of 3: 385 usec per loop
----------
status: unread -> chatting
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1121>
________________________________________
More information about the pypy-issue
mailing list