|
|
|
|
|
by andreasvc
4320 days ago
|
|
Your points (a) and (b) are specific to numerical code; perhaps Numba addresses these problems well but it's not something I've worked with. With regards to C and Cython, I wouldn't say "the whole point was to avoid writing low level code", because that is what can give you the most performance in the end. If you do want to avoid low level code then you'll prefer to approach with a single language such as Julia or Java, but this means trading the bare-to-the-metal performance for having a VM and JIT between the code and the machine. The argument of preferring writing C code to Cython code is moot because you have the choice of writing code in Cython or using it to wrap existing C code. While the second option allows you to write in C as you say you'd prefer, the first options offers seamless integration of C code and manipulation of Python datastructures, so there is an advantage to using Cython not just for wrappers but also for code. I'm a bit at a loss as to why you would claim I gave a rosy picture, or what this "self cheering" is about (note that my use of "ideal" was part of a conditional). I actually presented it as a dilemma (systems & scripting language, or a single language), and I think it's not clear which approach is better or whether the fact that there seems to be a dilemma is accidental or necessary. |
|
> The argument of preferring writing C code to Cython code is moot because you have the choice of writing code in Cython or using it to wrap existing C code.
I am not convinced about this and I have mentioned why I am not so enamored by this approach. Although quite a feat in itself Cython is not a very sophisticated compiler, so if you are writing C code you are better of taking charge and writing the C yourself. You get to enjoy the tooling that have accumulated over the years around the C syntax language. Otherwise you often get yourself in a solution that you have to debug the autogenerated C, not very pleasant. The second reason is that the bridge between Cython and C is by no means cheap. Note Cython's objective is to produce a Python C modules, not native C binaries, so it will talk to see with all the disadvantages of talking to C from a Python C module. Cython is indeed great if you have legacy code in Python that you would want to marry to C, or to get some speedup with minimal intervention, but if you are not so constrained and want more speedup than this affords perhaps better approaches are needed.
I would also point out that Julia does not always yield faster solutions than Cython yet. My main motivation was to point out some design issues that you are saddled with when you are a denizen in the Python world.