[pypy-dev] Matrix dot product

Skip Montanaro skip at pobox.com
Wed Jun 11 19:12:36 CEST 2014


On Wed, Jun 11, 2014 at 11:07 AM, Gayathri J <usethisid2014 at gmail.com> wrote:
> So find that the basic matrix dot operation is faster on python 2.7 than on
> pypy 2.2.1
> why is this so? am i missing something?

Warning: I am not a PyPy user, just an observer.

It looks to me like you haven't executed the dot product code enough
for PyPy's tracing code to recognize it as a critical path.
Consequently, you have only suffered from the JIT machinery startup
and execution tracing overhead, and haven't benefited from the JIT
compilation. You might try wrapping a loop around the a.dot(b) call:

for i in range(1000):
    c = a.dot(b)

I have a couple more nits which are not PyPy-specific:

1. When asking for help, it really helps to post code that actually
runs. Your code doesn't include the numpy import. You also must of
left off the "np." prefix in the assignment to a.

2. You don't need the c = np.zeros(...) call either. You just throw it
away two lines later.

Skip


More information about the pypy-dev mailing list