On Sat, Oct 8, 2011 at 11:48 AM, Mateusz Paprocki <[email protected]> wrote: > Hi, > > On 8 October 2011 04:40, Maciej Fijalkowski <[email protected]> wrote: >> >> Hi >> >> I did some benchmarking of sympy under PyPy. I would like some >> comments on the validity of benchmarks. I've use PyPy nightly from 7th >> of Oct, CPython 2.7 release and sympy git trunk. >> >> Benchmarks (also http://paste.pocoo.org/show/489351/) >> >> Those are picked specifically so time stays around 1-5s >> >> Run: http://paste.pocoo.org/show/489352/ >> >> As you can see PyPy does give *a bit* of an edge once the JIT warms >> up, although it's not a whole lot. We'll look how to make pypy faster >> on those. > > First, make sure that PyPy and CPython use the same ground (coefficient) > types: > from sympy.polys.domains import GROUND_TYPES > print "types: %s" % GROUND_TYPES > SymPy can pick up gmpy for this, instead of using pure Python types. To > force > usage of pure Python types, use the following code: > import os > os.environ["SYMPY_GROUND_TYPES"] = "python" > # now you can import sympy
Also, mpmath uses gmpy automatically if it's installed, independently of the polys ground types. You can disable it by setting the environment variable MPMATH_NOGMPY to some non-empty value (see sympy/mpmath/libmp/backend.py). Aaron Meurer > > Caching can seriously affect benchmarks, so I would disable it completely: > import os > os.environ["SYMPY_USE_CACHE"] = "no" > # now you can import sympy >> >> Is there any interest in making sympy more pypy friendly? > > Can you provide some guidelines how we can achieve this? > I was hoping that low-level stuff in SymPy should work well with PyPy, > e.g.: > from sympy import ZZ > from sympy.polys.factortools import dmp_factor_list > from sympy.polys.densearith import dmp_pow > from sympy.polys.specialpolys import f_6 > def bench_lowlevel_mv_factor(): > # factor(f_6**2) in ZZ[x,y,z,t] > dmp_factor_list(dmp_pow(f_6, 2, 3, ZZ), 3, ZZ) > This, however, gives results other than I would expect: > $ pypy bench.py > cache: no > types: python > bench_lowlevel_mv_factor 1.41745710373 > bench_lowlevel_mv_factor 1.37492704391 > bench_lowlevel_mv_factor 1.28843522072 > ... > $ python2.7 bench.py > cache: no > types: python > bench_lowlevel_mv_factor 0.23696398735 > bench_lowlevel_mv_factor 0.235101938248 > bench_lowlevel_mv_factor 0.238154888153 > ... > >> >> Cheers, >> fijal >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sympy" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/sympy?hl=en. >> > > Mateusz > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
