3 ms·
I maintain a program written in Python that is faster than the program written in C that it replaces. The C version can do a lot more operations, but it amounts
by sevensor 1y ago
I maintain a program written in Python that is faster than the program written in C that it replaces. The C version can do a lot more operations, but it amounts to enumerating 2^N alternatives when you could enumerate N alternatives instead.
Certainly my version would be even faster if I implemented it in C, but the gains of going from exponential to linear completely dominate the language difference.
- vhantz 1y agoYeah let's just compare apple to oranges
- igouy 1y agoOn sweetness? On sharp acidity? On weight?
- patmorgan23 1y agoSo you're saying two different programs implementing two different algorithms perform differently and that lets you draw a conclusion about how the underlying language/compliers/interpreters behave? Have you ever heard of a controlled variable?
- sevensor 1y agoI must have been unclear. C is faster. The Python program would be faster if I reimplemented it in C. However, Python makes it so much easier to transform the problem into a linear form that it’s a bigger win to use Python than to continue maintaining the C version. And that’s my point: raw execution speed is only helpful when you’re executing the right thing. Don’t discount how much easier it can be to implement the right thing in Python.