Hi Brian!
On Wed, Nov 17, 2010 at 1:12 PM, Brian Granger <[email protected]> wrote:
> Hi,
> The quantum stuff in sympy is coming along nicely. Addison and Matt gaves
> talks at the CA-Nevada APS meeting at Caltech a few weeks ago and the work
> was well received. We have also had some visitors in our department who
> work in quantum information and they have been interested in the physics
> aspects of sympy.
> I think sympy.physics has a huge potential, but we are already running into
> an issue that I want to bring up. We are going to need Cython code quite
> soon. There are simply many algorithms that are too slow in pure Python
> (many of the algorithms scale exponentially with some parameter that we want
> to be large). Roughly speaking, here are some options:
> 1) Allow Cython code in sympy, but put logic in setup.py to omit it if there
> is no compiler or the deps are not there. For some of the algorithms this
> would work great because we have slower numpy/scipy/pure python based
> versions that could be used if the fast version is not available.
> 2) Create separate mini-projects that just have the optimized Cython
> algorithms and put pure python code in sympy that can use it if it is
> installed. I am not very fond of this.
> 3) Completely remove sympy.physics and create a separate project with all
> the physics stuff that can use Cython anywhere. Again, I am not too fond of
> this as the presence of the physics stuff benefits sympy in significant ways
> such as enlarging the community and attracting new developers.
> My choice would be (1) (allow Cython code in Sympy, but make sure that sympy
> still builds and installs w/o it). Thoughts?
Definitely 1). We already use Cython in the sympy polys, and it's
optional. (I think it's also actually broken currently, but that will
be fixed.)
Simply use Cython, and do something like:
try:
import _optimized_stuff
except ImportError:
raise Exception("You need to compile SymPy with Cython.")
And the module will not be imported by default, so if you do:
"import sympy"
it will only import pure Python stuff, and if you do:
from sympy.physics.hydrogen import solve_rk4_fast()
it would either work and use Cython, or raise an exception.
Just implement it and let's get this code in sympy soon. Then we'll
keep refining it. We'll be using Cython at more places all round
SymPy, in this optional way.
Another, orthogonal feature to consider is the pure Python mode of
Cython. Maybe the Python code can work in pure Python mode (but slow)
and work faster if compiled with Cython. One just has to either use
decorators and/or .pxd files + .py files. Last time I tried it worked
for simple things, but not for more complex stuff. In any case, this
should not be a big deal, we can always use the method I described
above.
So the conclusion is, definitely use Cython!
Ondrej
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
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.