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
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.
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..
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
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.
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).