On Sep 30, 2013, at 5:04 PM, "F. B." <franz.bona...@gmail.com> wrote:


> @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
>
>
Such decorators could undergo a first phase of testing, i.e. checking
during the execution of the tests that those variables are indeed of the
type declared in the dict.

After successful testing of the staticity of internal variables, one could
use some existing Python to C++ translators combined with the dict in order
to generate C++ code.

This solution would have the advantage that coding is required only once,
in Python with some precautions. C++ code would be always up to date with
any edits in the Python code.

I know that *numba* has a similar approach using decorators, except that it
compiles the code just-in-time, which is a bit different. I don't know if
there is any existing project applying something like a decorator-based
translator.


Also numba targets llvm, which is really much smarter for what it is trying
to do, and it focuses mainly on numeric code that uses NumPy arrays. I know
there has been some work in trying to make numba more modular, though.
Maybe in the future, it would be possible to write a more OO backend to it,
or at the very least, teach it how to work with tree-like data structures.

Aaron Meurer

 --
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.

-- 
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