On Wed, Nov 17, 2010 at 4:57 PM, Brian Granger <[email protected]> wrote:
> Ondrej,
>
> On Wed, Nov 17, 2010 at 3:20 PM, Ondrej Certik <[email protected]> wrote:
>>
>> 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.)
>>
>
> Great!  This is fantastic news and will help us a lot.

Look at the Makefile. And do:

$ make
python build.py build_ext --inplace
Compiling module sympy.polys.densearith ...
Compiling module sympy.polys.densebasic ...
Compiling module sympy.polys.densetools ...

Error converting Pyrex file to C:
------------------------------------------------------------
...
            raise ValueError("can't refine a real root on (%s, %s)" % (s, t))

    fast = args.get('fast')

    if type(n) is not int:
        cond = lambda a, b, c, d, i, F: abs(F(a, c) - F(b, d)) < n
              ^
------------------------------------------------------------

/home/ondrej/repos/sympy/sympy/polys/densetools.py:2176:15: Expected
an identifier or literal
Traceback (most recent call last):
  File "build.py", line 31, in <module>
    raise RuntimeError("failed to compile %s" % module)
RuntimeError: failed to compile sympy.polys.densetools
make: *** [all] Error 1


so there is some bug. I guess just comment the nonworking code out, or
adapt the setup.py in some other way.

>
>>
>> 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.
>>
>
> Yes, that should work fine for us.
>
>>
>> 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.
>>
>
> Sounds good.
>
>>
>> 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.
>>
>
> Most of the stuff we really need Cython for will be quite complex, but I
> will definitely have a look at the pure python mode.

Looking forward.

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.

Reply via email to