4 ms·
I have serious reservations about headlines like this, but perhaps I'm being pedantic without realizing. My concern is that a particular mathematical function
by DoofusOfDeath 6y ago
I have serious reservations about headlines like this, but perhaps I'm being pedantic without realizing.
My concern is that a particular mathematical function can be expressed in many different ways using Python and using C++. And practically speaking, it's impossible to be sure that you've created the fastest-possible implementation of that function in either language.
And even then some implementations' performances are dependent on the compiler, supporting libraries, and underlying processor architecture.
So AFAIK a headline like this leaves out way too many details to be generally true. Am I missing something?
- Farmadupe 6y agoI think given the naive algorithm of both implementations, and the fact the python and cpp are near transliterations of each other, the article isn't really trying to make the literal statement of the words of its title. Of course the relationship between language semantics and actual raw performance on real hardware is probably a neverending topic. I guess the article is more trying to make a statement along the lines of "here's how you benefit if you know python and pretend that means you know CPP too", (which seems like a fairly valid way to suck people into learning CPP to me)
- adsharma 6y agoshameless plug: https://github.com/adsharma/py2many https://github.com/adsharma/py2many I didn't write the python -> C++ transpiler, but added a few features to common and added basic support in 6 other languages. It should be possible to generate the C++ from python.
- Rochus 6y agoInteresting. Do you have performance data (e.g. all CLBG Python benchmarks transpiled to C++ and run)? What's the speed-up?
- adsharma 6y agoI haven't focused on performance yet. Thanks for the pointer! Gives me a concrete target to go after. https://github.com/adsharma/py2many/tree/main/tests/expected https://github.com/adsharma/py2many/tree/main/tests/expected is a good place to understand what types of code this system can transpile. Most languages are using templates/generics/auto etc. I added some type inference capabilities to common code and updated dart to take advantage of it. Should be possible for other languages as well. btrees python -> C++/rust seems feasible as a point of comparison. Hard problem: translating library calls from one language to another. I'm thinking of some type of a plugin system that app developers can provide mappings.
- igouy 6y agoiow one tiny C++ program measured 9.4 times faster than one tiny Python program, is a statement about programs not about programming language implementations (or programming languages).