Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Rewriting everything from scratch is my favorite optimization :D
-pthread4561yI don't think you can gain that kind of performance boost by just switching langauge AFAIK even CPU bound process in c++ just provide 5x performance boost than python.
@-pthread Depends on specific case, I suppose, but I'd guess 10-15x achievable. Python's internal VM is rather rudimentary, it doesn't even apply trivial optimizations. On the other hand with C++ you're not only compiling to native code, but you also get compile-time optimizations. I'd expect that alone to give you 10x in some cases.
Can't python just be compiled into native code?
@OneOfSimpleMind there are some tricks to that (mostly tools):
Py2exe - literally just makes an executable that contains the python interpreter and the python source in one file. It's useful, but it's still interpreted. And the binaries are large.
Pyinstaller - see above
Nuikta - now we are talking! This is a python to c++ transpiler. Yes, it will compile to native machine code. No, it will not add much performance. The code it writes is machine generated. And is as good as you think machine generated code will be. ie oh my God is it unreadable.
I like nuikta. A lot actually. But it is not a performance enhancement thing. It does not compile python. It converts python into very functional, but very ugly, and likely non-optimizable C++.