# sympy/sympy

Cythonized zero-level algorithms in new polynomials module

```Pure Python:

In [1]: f = expand(((x+y+z)**15+1)*((x+y+z)**15+2))

In [2]: %time a = factor(f)
CPU times: user 109.45 s, sys: 0.01 s, total: 109.47 s
Wall time: 110.83 s

In [4]: %time a = factor(f)
CPU times: user 109.31 s, sys: 0.03 s, total: 109.34 s
Wall time: 110.68 s

Pure mode Cython:

In [1]: f = expand(((x+y+z)**15+1)*((x+y+z)**15+2))

In [2]: %time a = factor(f)
CPU times: user 72.09 s, sys: 1.02 s, total: 73.11 s
Wall time: 74.18 s

In [4]: %time a = factor(f)
CPU times: user 72.81 s, sys: 0.04 s, total: 72.85 s
Wall time: 73.74 s

On average Cython version is two times faster than pure
Python. This is an improvement and hopefully it should
get even better in future.

To make cooperation with Cython more comfortable a new

Example:

@cythonized('n,k')
def some_function(n):
return n**k

This means that `some_function` will be compiled by
Cython if available, treating variables n and k as
integers (cython.int). This is convenient because
currently we don't use any other types.

If Cython is not available then @cythonized is an
empty decorator (there is no performance penalty).

To take advantage of pure mode Cython, you have to
compile modules which support cythonization. To do
this, issue:

python build.py build_ext --inplace

in SymPy's root directory (or use make). Then run
isympy or import sympy as usually (compiled modules
will have priority over pure Python).```