On Wed, Oct 2, 2013 at 11:50 AM, F. B. <[email protected]> wrote: > > > On Wednesday, October 2, 2013 10:53:10 AM UTC+2, Björn Dahlgren wrote: >> >> I've played around with Cython, Nuitka, shedskin etc. I would not >> recommend Nuitka (see Stefan Behnels blog post on the topic) - furthermore: >> it produces huge binaries. > > > Maybe you're right, but I would keep an eye on these projects. > >> >> Based on what I've read lately mypy might be the silver bullet but it's >> quite new and I haven't found >> the time to play around with it yet. > > > That uses annotators, it would break compatibility with Python 2. > >> >> On the note of de dynamizing the code base it might be worth looking into >> param: >> https://github.com/ioam/param >> >> http://pyvideo.org/video/1230/param-declarative-programming-using-parameters >> > > Sounds good, but that could be used simply to keep the code clean. > >> >> I've also played around automatic (cython) code generation of decorated >> classes >> https://gist.github.com/bjodah/6790854 >> (requires Py3, cython & mako) but it got cumbersome so I didn't go any >> further. > > > Indeed, you're right, translating Python to Cython is much easier than > translating Python to C/C++, in fact Cython could work even if no > translation takes place at all. > > Maybe that could be a candidate proposal as valid alternative to CSymPy. > > One could write a decorator to add both signature of parameters, and types > of internal variables inside the function. Maybe then add a test in sympy's > utilities to check that all local variables inside the function are signed, > and write a tool similar to the previous 2to3, maybe sympy2cython, to create > a cython optimized code. > > What about this? It is far easier than writing CSymPy in C++ by hand, or > trying translation into C++.
The problem with Cython is that I am not able to make it as fast as CSymPy in C++, and I tried: https://github.com/certik/sympyx/blob/master/sympy_pyx.pyx The reason is that to truly nail the speed, one needs to use special dictionary implementation, tweak hashing functions, reference counting, memory allocators etc. C++ allows to play with all that, while having a reasonably high level syntax. In Cython one has to use Python types like hashes/dicts ---- or resort to effectively writing a pure C code --- either way, it becomes overall more complex than just writing things in C++ by hand. So I'll be happy to be proven wrong, but so far C++ is a clear winner in terms of speed. Besides speed, I came to appreciate having just one language and write everything in it. Much simpler to maintain and master. With your sympy2cython approach, you need to master Python, SymPy code, the sympy2cython tool, Cython, C and Python C/API intricacies. That's a lot of layers. The reason to do this is speed, otherwise we can just use SymPy --- but to nail speed, you need to master all these layers extremely well, and it might still not be enough --- i.e. I think I know Cython and Python C/API reasonably well, but I don't know how to make the Cython code above as fast as CSymPy. In C++, on the other hand, you can really nail the speed and it is just one language to master and maintain. Ondrej -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
