3 ms·
In a nutshell, because none of those facilities are really designed for writing your whole program in. If you have a program whose runtime is dominated by a fe
by comex 8y ago
In a nutshell, because none of those facilities are really designed for writing your whole program in. If you have a program whose runtime is dominated by a few very hot functions, probably numerical, then numpy, Numba, and Cython are all decent options for making those functions fast, and you can use the full power of Python for the rest of your code. But if you have a big fat codebase where just about everything is lukewarm – and that describes a lot of programs – then you need everything to be fast. It's certainly possible to write a whole program in Cython, using static C types for everything and minimizing interaction with the Python world, but … well, nobody does that. As in, I've never seen a single large pure-Cython codebase, though I wouldn't be surprised if some exist.
- mlthoughts2018 8y agoI’m not sure how this is related to its parent comment thread, but in any case I agree with it, and would view this as supporting my point. In my experience, a big lukewarm codebase is exceedingly rare, and often gets that way because there was premature optimization in the form of assuming the project had to be written in this or that language way back at the beginning, without there ever having been a prototype stage when multiple implementation languages were actually tested. And even given that, it takes a special kind of alignment of the stars for the usage patterns, resource limits, and language tools to all work out properly for a system with few hotspots. But regardless, I do agree there are plenty of cases when it can be the right choice to presume a need to write the whole thing in C/C++. Examples become irrelevant though when they try to do a horse race comparison of a contrived, unoptimized Python example with a C/C++ example that would be more optimal out of the box just due to intended differences in the languages. Because these examples are exactly like targeted hotspot optimization, which would be the case when Python augmented with Cython/numba is a stronger contender.