On Tuesday, October 1, 2013 12:07:07 AM UTC+2, Jason Moore wrote:
>
> "Or maybe even try to define a standard to write Python code in order to 
> make it easy to translate it to C++ through code generators?"
>
> Doesn't Cython already do this?
>

In cython, if you don't use *cdef*, all variables are translated into *
PyObject* pointers, which is practically the same as dynamic 
typing. Therefore a naive usage of cython would not give any speed 
improvement.

On the other hand, using *cdef* breaks compatibility with standard Python, 
and code becomes Cython-only.

In order to achieve high performance types have to be static, so maybe a 
solution for a C++ version of SymPy would be to add a dictionary of 
remapping of the variable types, for example:

@is_cpp_translatable
class SomeClass(Basic):
    @staticvars({'a': 'int', 'b': 'int', 'c': 'double'})
    def simple_method(a, b):
        c = a // 2 + b // 3
        return c

which would give

class SomeClass : public Basic {
    public:
        double simple_method(int a, int b) {
            double c = ((double)a)/2 + ((double)b)/2;
            return c;
        }
}



-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to