Open In App

What makes Python a slow language ?

Python is a high-level language (than C or C++) thus Python itself manages details of a program like memory allocation, memory deallocation, pointers, etc. This makes writing codes in Python easier for programmers.  Python code is first compiled into python Byte Code. The Byte Code interpreter conversion happens internally and most of it is hidden from the developer. Byte code is platform-independent and lower-level programming. Compilation of byte code is to ramp up the execution of source code. The source code compiled to byte code is then executed in Python’s virtual machine one by one, to carry out the operations. The virtual machine is an internal component of Python.

Internally Python code is interpreted during run time rather than being compiled to native code hence it is a bit slower. 



Running of Python script v/s running of C/C++ code:

Python: First it is compiled into Byte Code. This Byte Code is then interpreted and executed by the PVM (Python Virtual Machine).



C/C++: The source code is compiled into Binary Code which can be directly executed by the CPU making them more efficient.

Major Reasons for Python being slow:  

Article Tags :