On Mon, Mar 8, 2010 at 3:40 PM, Maciej Fijalkowski <fij...@gmail.com> wrote: > On Mon, Mar 8, 2010 at 1:55 PM, Ondrej Certik <ond...@certik.cz> wrote: >> On Mon, Mar 8, 2010 at 11:53 AM, Maciej Fijalkowski <fij...@gmail.com> wrote: >>> Hello. >>> >>> Half a year ago, I was asking about sympy benchmarks. So here is some >>> feedback on what I got using the JIT. Running the very simple >>> benchmark, like this: >>> >>> import sympy >>> import time >>> x, y = sympy.symbols('x, y') >>> >>> for i in range(10): >>> t0 = time.time() >>> sympy.factor(x**20 - y**20) >>> print time.time() - t0 >>> >>> (I run it 10 times for JIT to warm up) >>> >>> I get the following results: >>> >>> CPython 2.6.4: >>> >>> 0.894039154053 >>> 0.738809108734 >>> 0.749840021133 >>> 0.817865848541 >>> 0.72897195816 >>> 0.771667957306 >>> 0.777043104172 >>> 0.770677089691 >>> 0.770140886307 >>> 0.877714157104 >>> >>> PyPy trunk (rev 71774): >>> >>> 1.19711208344 >>> 0.634068012238 >>> 0.557782888412 >>> 0.614212036133 >>> 0.521821022034 >>> 0.577347993851 >>> 0.481374979019 >>> 0.466244935989 >>> 0.444444894791 >>> 0.520822048187 >>> >>> So overal we get some (not too much) speedup, after warmup, without >>> even profiling that case. I suppose we can do much better if we try >>> slightly harder. >> >> Also note that sympy uses caching, so you might try it with caching turned >> off: >> >> http://wiki.sympy.org/wiki/FAQ#How_do_I_turn_off_caching.3F > > It seems to be irrelevant for this particular example. > >> >>> >>> What do you think? Is it an interesting direction to pursue? Are >>> people interested? >> >> I am interested. What kind of things can pypy compile in time using JIT? > > In general all Python. It can perform better on some stuff and worse > on some stuff (combinations of map/reduce being particularly nasty, > loop being much much faster for example). > > I can perform some more benchmarking, if you happen to have some more > comprehensive bench suite than just this :-)
Try divisors() from sympy/ntheory/factor_.py. I tried that with Cython (pure Python mode, so that you have the same source code, that works both in Python and in Cython) and I forgot which speedup I got, but at least 10x, maybe up to 25x. Should be in the archives of this list. Ondrej -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sy...@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.