On Jun 9, 11:13 pm, "Gary Furnish" <[EMAIL PROTECTED]> wrote:
> After Pearu suggested I give the microbenchmark on sympycore a try, I
> can't seem to get more then 9000 expands on recent hardware.
> I am running:
>
> In [54]: a,b,c = Rational(1,2), Rational(2,3), Rational(4,5)
> In [64]: %timeit (3*(a*x + b*y + c*z)).expand()
> 10000 loops, best of 3: 110 µs per loop

With your python session, I get

>>> %timeit (3*(a*x + b*y + c*z)).expand()
10000 loops, best of 3: 74.5 µs per loop

So, the test runs in my computer (Intel Core 2 T7400)
1.47 times faster.

> How can I fix this?

There are three things:

1) You must use sympycore from svn, it is faster than
sympycore-0.1.

2) Note that calling expand is not required because
sympycore expands number*sum automatically:

>>> 3*(a*x + b*y + c*z)
Calculus('12/5*z + 2*y + 3/2*x')

So, this will give another speedup:

>>> %timeit (3*(a*x + b*y + c*z))
10000 loops, best of 3: 53.4 µs per loop

3) You have not build the small extension module that
sympycore has. Try this in svn/sympycore/trunk:

$ python setup.py build_ext --inplace
$ python
>>> from sympycore import *
>>> x,y,z,v,w=map(Symbol,'xyzvw')
>>> a,b,c = Rational(1,2), Rational(2,3), Rational(4,5)
>>> %timeit (3*(a*x + b*y + c*z))
10000 loops, best of 3: 31.8 µs per loop
>>> 1/(31.8*1e-6)
31446.540880503144

That's almost 32k. Note that the results in the web page
are obtained using run1test.py script and somewho the tests
run about 3% faster when executed from a script compared when
executing them from a interactive session.

> Also, how do I disable caching for sympycore?

sympycore does not use caching.

However sympy does use caching and it is important to disable caching
for the given test. Otherwise the test would just measure how fast
the cache can return the result, not how fast sympy can create
expressions which this test is all about.

Regards,
Pearu
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to