+ 2
executable (.exe) file
if I write a program in python, similar program in c++, then both program are converted to exe. exe file contains binary code. So will both executable behave similarly or they have difference in their memory management, speed etc.
5 odpowiedzi
+ 1
@Andrew, if they have similar logic. This implies that the algorithm involves the same complexity. Well c++ will be faster. One reason for this is that c++ is compiled directly into machine code.
Although both are in .exe file, the python .exe file will have an embedded interpreter behind the scenes that will add an overhead to the total runtime.
+ 3
It depends on the implementation. A poorly written c++ program will run slower than a well written python program. It's not a rocket science thing.
The same thing applied for an executable. C++ has a direct access to memory addresses and can utilize these for fast programs. If the programmer misuse it, then it may be the reason for slowness
+ 3
White Shadow okay suppose both are having similar logic. then converted to exe. exe has binary and not related to any programming language.
In general we say python is slower than c++
So, can we say that exe from c++ is faster than exe from c++
+ 2
Definitely yes, when it comes to speed. You can test it by creating an array of random numbers in both applications and then use a bubble sort method on both arrays. Fill the arrays with 1000000 random numbers and you will see that c++ is much faster to sort an array, even though you have created a python executable file.
+ 1
Let me say it that way, python is quite slow if you are working with big lists, and that's not for discussion. You can increase the speed by using a set() in some operations, but since it's unordered, then it won't be reliable in all operations.