Open In App

Python | Compiled or Interpreted ?

Last Updated : 24 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Please note that Python language standard does not specify whether the code is to be compiled or interpreted or both. It depends upon the implementation or distribution of a Python language. The most common implementations of Python like CPython do both compilation and interpretation. The compilation part is hidden from the programmer thus, many programmers believe that it is an interpreted. The compilation part is done first to convert the given Python code (or .py) to a byte code. Then this byte code gets converted by the python virtual machine(p.v.m) according to the underlying platform(machine+operating system). Now the question is - if there is any proof that it first compiles the program internally and then run the code via interpreter? The answer is yes! and note this compiled part is get deleted by the python(as soon as you execute your code) just it does not want programmers to get into complexity.

Code : Sample Python code

Python3 1==
print("i am learning python")
print("i am enjoying it")

now if you run this code using command prompt just save this above code in notepad and save with the extension ".py"

syntax:

python (name of the program.py) and press enter.

Note:

If you are writing code in the notepad just save the code with extension "py" inlet suppose you have created a folder named python_prog in d drive.

as you press enter the byte code will get generated. A folder created and this will contain the byte code of your program. This folder is in the python_prog folder where you will save your python codes.

now to run the compiled byte code just type the following command in the command prompt:-

the extension .pyc is python compiler.. Thus, it is proven that python programs are both compiled as well as interpreted!! but the compilation part is hidden from the programmer.


Next Article
Article Tags :
Practice Tags :

Similar Reads