Why python is slower than c+?

python is used for advanced purposes.

4/13/2017 10:44:22 AM


40 Answers

New Answer


Internally the reason that Python code executes more slowly is because code is interpreted at runtime instead of being compiled to native code at compile time. ... The reason why CPython doesn't have a JIT compiler already is because the dynamic nature of Python makes it difficult to write one


Python is interpreted, c/c++ compiled. So no comparison should be made on speed. c/c++ will be always faster.


This is because C++ is typically a compiled language, meaning it is transformed into machine code and stored as an executable file. When any language is compiled it is transformed into instructions that are specific for the machine it is compiled on, all of the interpretation of the code is made during this compilation time. At runtime the instructions created by the compiler are 'read' and executed step by step by the CPU. On the other hand python is an interpreted language with much higher level constructs. This means that at runtime the interpreter needs to understand your code, check that it is valid in the current program instance then create instructions for your CPU to execute then pass it to your CPU. Overall, because python is typically interpreted all of its understanding and interpretation of your code is done at runtime which makes it seem like it is 'slower' then C++, whereas all the C++ interpretation was done at compile time.


Also, C++ is a low level language what means it takes less time to convert C++ code to machine languages (1's and 0's) thats why C++, assembly etc are little harder to learn but faster in program


Python is generally slower than C/C++ for a simple reason: it's an interpreted language, while C/C++ is not. ... also, Python is slower than C/C++ because Python is written in C. Python is a high level language, and that has good and bad aspects.its speed is trade of with it's flexibility..


C++ is a lower level, compiled language. Its beauty lies in its simplicity.


interpretetor > compiler > machine code compiler > machine code


because c is the Base of python . python s ancestor is c ;)


Python interprets(i.e. works on the code line by line) while C++ compiles the whole block as a whole… so def C++ will just be fast… But to me either way, i still prefer python


Python is just as powerful with it's scripting abilities.


Because python is a interpreted language and c++ is a compiled language


Python is interpreted that means when you write the code it starts running. Cpp is complied. you have to write the code first. until then it'll not do anything. more on www.Cppreference.com www.python.org www.syntaxdb.com


pythonis interpretted lang


and because python has many shortcuts comming from a programming interface such as c


Several major reasons are:- 1.Phython is interpreted,while C++ is compiled. 2.Phython has no primitives,everything including the builitin types(int, float etc.) are objects. 3.A phython list can hold object of different types,so each entry has to store additional data about its type. These all severely hinder both runtime and consumption.


Programmer time is far more expensive than user time. The difference in speed between Python and C++ is so small that it becomes irrelevant compared to the hundreds, maybe thousands of hours that can be saved in development using Python.


just to add, considering you already understood the answers given by others. when you package your program, it is interpreted during its first run only. For future execution, python creates a compiled file of your python script and stores it in order to save time. So, it wouldn't matter much.


because Python is a scripting language and there for it is Interpreted while C++ is a programming language which make it Compiled


Python uses a language like c++ as an interpreter. So python code can not be compiled in order for c++ to read it. This is more efficient for the developer at the cost of speed. For instance, I do 10,000 operations a seconds in c++. Where as in python i can only do 2,000. The big difference is that python code has to be read by c++ and then operations are performed. Although python is faster than most scripting languages, python is also much much easier to write and read than most scripting languages. If you are going for speed try using a language like c++ as it get compiled to asm(machine language).


it's because python run larger amounts of code in one short line, bit it's not all that slower, try a new editor at python .com