Python inner working
Ever wondered what really happens when you run a Python program? Let's break it down.
When you run a Python program, it gets turned into something called bytecode, which is like a simpler version of the code. This bytecode helps the program run faster and work on different types of computers.
Python comes with something called the Python Virtual Machine (PVM). It's like a translator that takes the bytecode and turns it into actions your computer understands. This happens in a loop, where the PVM keeps interpreting the bytecode and giving you the results.
This PVM converts the bytecode into machine code, which is understood by the machine, allowing us to get the desired output according to the program.
After the bytecode is done running, Python creates a file with a ".pyc" ending. This file has the bytecode saved, so next time you run the program, it can use this saved bytecode to run faster, as long as the code hasn't changed. But these ".pyc" files only happen when you're using imported files, not standalone ones.
#ChaiCode
Reference-
Subscribe to my newsletter
Read articles from Himanshu Rai directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by