Python beyond Just Syntax
Python is one of the most fun programming language out there, with easy to read syntax and due to its extensive use in domains of WEB-DEV, ML/AI, DATA SCIENCE making it one of the most useful modern language in today's scenario.
But learning languages are not just about syntax , modules, or functions it is also gaining knowledge about how things works behind the scene...
how does python works behind the scene?
Byte Code
whenever you write a python code it gets converted to byte code , which is a low-level code NOT #MACHINE-CODE# , which is faster in execution as compared to the original python code. It is python specific so cannot be executed on other engines. It contains instructions to the PYTHON VIRTUAL MACHINE(PVM), with extension ".pyc". It is mostly hidden but when you import a file into your code it is visible under the folder name __pycache__ .
(To indicate a folder or a file which is made by python for it's own function is represented by two '_' at the start and beginning of the name.)
creating a simple hello world program and importing it into another file
Python Virtual Machine(PVM)
PVM is python's engine to execute code.The Byte-code goes to Python-Virtual-Machine where it gets converted into machine code and is further executed , and if there is any error the concerned message is been displayed. Byte code makes thing faster for PVM , as when the .pyc file is being created all the syntax errors are also checked, in PVM the byte code is converted to machine code for further execution
learn more about inner working in this video:
Subscribe to my newsletter
Read articles from Yatharth Srivastava directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Yatharth Srivastava
Yatharth Srivastava
I am Yatharth a Full Stack Developer who loves building new projects and figuring how to make them for real world.