Le 14/03/2013 20:16, Ondřej Čertík a écrit :
On Thu, Mar 14, 2013 at 7:50 PM, Ronan Lamy <[email protected]> wrote:
Le 14/03/2013 09:42, Ondřej Čertík a écrit :
In general, I think it's quite amazing how fast Python actually is,
that sympy can compete very well
with for example Maxima, if the right data structures and algorithms
are used. So I think it's a good idea
to keep sympy in pure Python. But have an optional C++ core is
something that I feel is necessary, if nothing, at least to have an
idea of how fast one can get.
If you want to see how fast one can get, it's probably way easier to use
PyPy (making sure that you're measuring jitted code, and to exclude the
compilation overhead).
Hm, our Cython code (https://github.com/certik/sympyx) is much faster
already than anything that I was able to do in pypy. But maybe they
got faster. I'll be happy to be proven wrong.
sympyx is only a toy model, so I don't know how much it can actually
tell us about sympy. But anyway, I find that after warm-up, PyPy is
faster than Cython.
I modified benchmarks.py to run everything 3 times. See the results in
the attached file.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
With Cython (0.18):
(sympyx)~/dev/sympyx$ python benchmarks.py
I: import sympy_pyx ... ok
I: Running SymPy
e=(x+y+z+1)**10;f=e*(e+1);f.expand(): 0.206392
e=(x+y+z+1)**10;f=e*(e+1);f.expand(): 0.276263
e=(x+y+z+1)**10;f=e*(e+1);f.expand(): 0.239160
e=(x+y+z+1)**10; f=e**2+e; f.expand(): 0.215511
e=(x+y+z+1)**10; f=e**2+e; f.expand(): 0.205441
e=(x+y+z+1)**10; f=e**2+e; f.expand(): 0.211290
e=(x+y+z+1)**20; f=e**2+e; f.expand(): 1.842310
e=(x+y+z+1)**20; f=e**2+e; f.expand(): 1.700029
e=(x+y+z+1)**20; f=e**2+e; f.expand(): 1.887460
e=(x+y+z+1)**30; f=e**2+e; f.expand(): 7.432506
e=(x+y+z+1)**30; f=e**2+e; f.expand(): 7.278717
e=(x+y+z+1)**30; f=e**2+e; f.expand(): 7.078796
e=(x+y+z+1)**10; e.expand(): 0.012245
e=(x+y+z+1)**10; e.expand(): 0.011970
e=(x+y+z+1)**10; e.expand(): 0.011358
e=(x+y+z+1)**50; e.expand(): 1.423194
e=(x+y+z+1)**50; e.expand(): 1.618481
e=(x+y+z+1)**50; e.expand(): 1.606616
e=((x**x+y**y+z**z)**10 * (x**y+y**z+z**x)**10); e.expand(): 0.936832
e=((x**x+y**y+z**z)**10 * (x**y+y**z+z**x)**10); e.expand(): 0.982656
e=((x**x+y**y+z**z)**10 * (x**y+y**z+z**x)**10); e.expand(): 0.993231
Add(x,<random integer>,y), 2000x: 0.140276
Add(x,<random integer>,y), 2000x: 0.099994
Add(x,<random integer>,y), 2000x: 0.099046
Mul(x,<random integer>,y), 2000x: 0.066010
Mul(x,<random integer>,y), 2000x: 0.066752
Mul(x,<random integer>,y), 2000x: 0.066383
sum(x**i/i,i=1..400): 2.239066
sum(x**i/i,i=1..400): 2.215317
sum(x**i/i,i=1..400): 2.213977
sum(x**i/i,i=1..400), using Add(terms): 0.022982
sum(x**i/i,i=1..400), using Add(terms): 0.025250
sum(x**i/i,i=1..400), using Add(terms): 0.022686
With PyPy (recent nightly):
(sympyx)~/dev/sympyx$ ~/pypy benchmarks.py
I: import sympy_pyx ... fail (No module named sympy_pyx)
W: can't import sympy_pyx -- will be pure python
I: Running SymPy
e=(x+y+z+1)**10;f=e*(e+1);f.expand(): 2.800128
e=(x+y+z+1)**10;f=e*(e+1);f.expand(): 0.693211
e=(x+y+z+1)**10;f=e*(e+1);f.expand(): 0.343898
e=(x+y+z+1)**10; f=e**2+e; f.expand(): 0.344710
e=(x+y+z+1)**10; f=e**2+e; f.expand(): 0.358126
e=(x+y+z+1)**10; f=e**2+e; f.expand(): 0.256193
e=(x+y+z+1)**20; f=e**2+e; f.expand(): 1.751092
e=(x+y+z+1)**20; f=e**2+e; f.expand(): 1.510628
e=(x+y+z+1)**20; f=e**2+e; f.expand(): 1.469288
e=(x+y+z+1)**30; f=e**2+e; f.expand(): 5.207019
e=(x+y+z+1)**30; f=e**2+e; f.expand(): 4.889063
e=(x+y+z+1)**30; f=e**2+e; f.expand(): 4.851042
e=(x+y+z+1)**10; e.expand(): 0.013060
e=(x+y+z+1)**10; e.expand(): 0.021414
e=(x+y+z+1)**10; e.expand(): 0.013148
e=(x+y+z+1)**50; e.expand(): 1.275716
e=(x+y+z+1)**50; e.expand(): 1.243164
e=(x+y+z+1)**50; e.expand(): 1.260820
e=((x**x+y**y+z**z)**10 * (x**y+y**z+z**x)**10); e.expand(): 3.215953
e=((x**x+y**y+z**z)**10 * (x**y+y**z+z**x)**10); e.expand(): 1.011673
e=((x**x+y**y+z**z)**10 * (x**y+y**z+z**x)**10); e.expand(): 0.669722
Add(x,<random integer>,y), 2000x: 0.236060
Add(x,<random integer>,y), 2000x: 0.021444
Add(x,<random integer>,y), 2000x: 0.021820
Mul(x,<random integer>,y), 2000x: 0.312406
Mul(x,<random integer>,y), 2000x: 0.010244
Mul(x,<random integer>,y), 2000x: 0.011146
sum(x**i/i,i=1..400): 2.590295
sum(x**i/i,i=1..400): 1.763554
sum(x**i/i,i=1..400): 1.921225
sum(x**i/i,i=1..400), using Add(terms): 0.038884
sum(x**i/i,i=1..400), using Add(terms): 0.068644
sum(x**i/i,i=1..400), using Add(terms): 0.107886