+ 1

what's the reason that c++ is a fast language and python is slow language

6th Jan 2018, 1:40 PM
Sachin
Sachin - avatar
2 odpowiedzi
+ 10
Python is scripting language , C is programming language When you run python script interpreter will interpret script line by line and gives output but in C ,compiler will first compile it and generates a.out which is optimized wrt your hardware . Thus C/C++ is relatively fast compared to Python You can write time consuming part in C rather than writing in python refer cython for it .
6th Jan 2018, 1:47 PM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
+ 1
There are a few reasons. The first, and probably most important, is that Python is interpreted, which means that a program runs and looks at each piece of code, decides what it is meant to do, and then executes it, whereas C++ is compiled, which means that it is turned into machine code, which is what computers read, before it is executed. This skips the step of another program reading and executing another program. The other reason is that Python is a very simple language. Faster languages are more similar to machine code, which requires you to do everything manually, so for a language that is less like that, one line of code may be 20 in a faster language.
6th Jan 2018, 3:22 PM
Jacob Pembleton
Jacob Pembleton - avatar