Reputation: 10891
For my code, I need to solve many Pell's equations quickly. Using just sympy 1.0 and python 3.5, calling diop_DN(q, 1)
runs at about 60 equations/sec. I took a look at the source code for diop_DN
solver and it appears it is written in pure python. So I tried running my code with pypy 5.1.2 (python 2.7.10) with sympy 1.0, but to my surprise it runs about twice as slow.
Is this expected behavior? Shouldn't pypy be able to run pure python faster?
Upvotes: 2
Views: 239
Reputation: 12900
You are likely not giving PyPy enough time to warm up. If I run diop_DN(13, -4)
in a loop, it takes more than 50 iterations to break even but the asymptotic time is about 5x faster than on CPython. If, as in real code, you are not doing all the calls with the same arguments, it might take even a bit longer to warm up. (Times measured with PyPy 5.6; with the older PyPy 5.1 the warm-up may be a bit longer, too.)
Upvotes: 2