Is Python Slower than C++/Java?
Yes! It is.
Python is an interpreted programming language whereas Java and C++ are compiler-based programming languages. The answer to our question boils down to one discussion, which is knowing the differences in the working of a compiler and an interpreter.
Python, as discussed, is an interpreted language which means that the language processor used in this language is the interpreter. An interpreter converts the source code which is written in a high-level programming language(python here) into a machine code which is in the form of 0’s and 1’s(binary).
In this process, the compilation and execution occur simultaneously. Each line of the source code is read, analyzed, compiled(translated) and then executed. Upon successful completion of this process in each step, the control goes to successive lines in the source code.
C++/Java on the other hand are compiler-based languages, which means that the language processor used in this language is the compiler. A compiler converts the source code to an object code(intermediate code between source and machine code) upon compiling, and after linking, it starts executing to give output. Unlike Python, C++ and Java read, analyze the entire file(all the lines) from the source code and upon successful compilation of the entire file, the execution starts. Though all this sounds like a tedious process as reading and processing the entire source code will take a lot of time. The overall execution time is comparatively lower than Python.
Debugging is much easier in an interpreted language as the errors can be handled and corrected at each line rather than waiting for the compilation of the entire document. Interpreters take less amount of time to analyze the source code but the overall time of execution is very much low.