We normally use python editors where one click makes our program run. So we don't know what exactly happens behind the hood.
Today we are going on a new journey to find the reality behind program execution!
This time we just need a python editor, command prompt and the _pycache_ folder to get this all done !
Dont worry about the _pycache_ folder as we will create it in some time 😃
🚶Without any further ado, let's begin our journey🚶
- First of all write a python program and save into your PC with a file name.
2. Now we need our CMD to locate this file and compile it. Yup, Compile !!
Compilation syntax — python -m py_compile filename.py
3. Once compilation is done there will be a folder created to hold cpython file (in my case _pycache_)
4. Now we will interpret or execute the cpython file
Execution syntax — python filename.pyc
We normally skip this compilation part and directly use execution command on python file and it internally creates, executes the cpython file (byte code) using python virtual machine so we never find any such cpython files.
Now, as we have seen the python compilation and interpretation with our eyes lets say “Python is both compiled and interpreted language”
Hope you liked this wonderful journey !
Happy learning !