I am new to this coding thing, but always curious to know behind the scenes of how everything works. All thanks to top-class shows like "How Do They Do It" and "How It's Made." Recently, I started learning Python with the help of Chai aur code by Hitesh Chaudhary, so here is what I learned.
Basically Python is a language of interpreted nature, that’s make it an excellent language for scripting and rapid application development .
Like other languages, Python does not translate its code into machine code, which is not understandable by hardware. Instead, the information changes into a format known as byte code (.pyc). Note that compilation happens, but not into machine code. Since the CPU does not understand byte code, we use a program called the Python Virtual Machine to make it work.
Step 1. Compilation into byte code - When you write source code after checking for any syntax error , code compiles to byte code ,these files have a .pyc extension, also called frozen binaries and it can be used cross-platforms , you can see it in your code editor only when you are importing from another files , it will look like “ *filename(imported from ).cpython-312.pyc” under a folder name __pycache__ Its made coz everything we change something in source code the byte code will change (using inbuilt algos), to prevent from stacking all those newer versions files/binaries/byte code in the machine’s folder python uses a system folder we discussed earlier.
Step 2- Byte code to output - As we know byte code is not a machine code and its python specific so we use a interpreter called python virtual machine is the only runtime engine for python , every online python interpreter use this in BTS.
*cpython-312 = cpython shows which variant of Python we are currently using and -312 shows the version.
Thank you Adios .