Hi. I am a developer for the project SymPy [0], which is a computer algebra system written in Python. We have been considering moving part or all of the code base into Cython for speed reasons. Ondrej Certik, the project's leader, recently gave a tutorial at SciPy09 (there should be a video up soon), which included a bit about increasing the speed of an operation by about 20x by using the cython.locals() decorator to convert some of the variables into cython ints. You can pull from his github account [1]. If you run:
>>> from sympy import * >>> d = divisors(5*10**7) The function will run about 20x to 30x faster, as I mentioned. But if you run the ntheory test, which uses divisors, using $./bin/test sympy/ntheory it runs slower or at least as slow as without cython. We figured out that the reason is that when the multiple imports in the tests are called, they run about 2x slower with cython, because it calls the decorator each time. You can see this by running In [1]: %timeit from sympy import * with and without cython in IPython. Is there any way around this? This could be a show stopper for us, because the increased import times levels out or makes worse the total times for things. This is not exclusive to the test suite. It comes from multiple imports in each file. We know that we can use .pxd files, but that would require to handle both .pxd files and .py files instead of maintaining one file with everything. Aaron Meurer [0] - http://code.google.com/p/sympy/ [1] - http://github.com/certik/sympy/tree/cython _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
