1. Source Code (Python Code):
Aap jo code likhte ho (
.py
file) usse source code kehte hain.Example:
pythonCopyEditprint("Hello, World!")
2. Conversion to Bytecode:
Jab aap Python code run karte ho, Python ka interpreter us code ko bytecode me convert karta hai.
Bytecode ek low-level code hota hai jo Python Virtual Machine (PVM) ke liye samajhne layak hota hai.
Bytecode files
.pyc
(compiled Python) extension ke saath banayi ja sakti hain, jo speed badhata hai.Example:
Aapka
print("Hello, World!")
bytecode me kuch is tarah dikh sakta hai (simplified version):objectivecCopyEditLOAD_NAME 'print' LOAD_CONST 'Hello, World!' CALL_FUNCTION 1 RETURN_VALUE
3. Execution by Python Virtual Machine (PVM):
Bytecode ko Python Virtual Machine (PVM) execute karta hai.
PVM us bytecode ko native machine code (CPU instructions) me translate karta hai aur phir system ke hardware ke hisaab se run karta hai.
Native machine code wo language hai jo computer ka processor samajh sakta hai.
Simplified Flow:
- Source Code (.py) → Bytecode (.pyc) → Native Machine Code → Output on Screen
Important Note:
Python is an interpreted language, iska matlab hai ki runtime par hi bytecode generate hota hai (agar
.pyc
file pehle se available na ho).Agar aap kisi program ko bar-bar run karte ho,
.pyc
file create hone ke baad performance thoda fast ho jata hai, kyunki direct bytecode use hota hai.
Aapka samajh clear hai! Agar aapke paas koi aur confusion hai, to puchhiye. 😊
agar na samjhe to ye image dekhe samjhe