[pypy-issue] [issue1526] Faster cffi/numpypy array data pointer casting (ndarray.ctypes?)
mikefc
tracker at bugs.pypy.org
Fri Jul 5 04:38:00 CEST 2013
mikefc <coolbutuseless at gmail.com> added the comment:
I should have pointed out that this is for 10million function calls each.
Note that in PyPy, the pure python dotproduct is 3x faster than the numpypy one.
I guess the overhead in setting up iterators/whatever in numpypy for these short (length=4) vectors makes it more
expensive than just the manual unrolling of the pure python version.
##############################
# CPython
##############################
As an extra example, I looked at running this under CPython2.7. Even the fastest version under CPython is slower
than the slowest pypy code.
And I've just found out that the ndarray.ctypes attribute is probably being created at call time, so no wonder it's
slower than casting the __array_attribute__.
numpypy dot 0.797430430847 0:00:11.081040
python dot 0.797430430847 0:00:30.281586
c dotproduct (cast to double *) 0.797430430847 0:01:21.851521
c dot. casting a.ctype.data 0.797430430847 0:02:14.366188
c dotproduct (cast outside loop) 0.797430430847 0:00:05.795226
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1526>
________________________________________
More information about the pypy-issue
mailing list