Computers can only understand the code written in machine language. Machine language usually involves instructions written in binary form i.e 0’s & 1’s. Hence, in other words, we need a software that can convert our high level code to machine code – we use compiler.
In procedural programming languages like C, compiler directly converts our source code to a machine code. However, in a language like Python, compiler only converts our source code to byte-code. When a python code is compiled, a file (set of instructions ) is generated. this is referred to as Byte code. It is Byte code only, which makes python platform independent. Size of each byte code instruction is 1 byte.
Role of Python Virtual Machine (PVM) is to convert the byte code instructions into machine code that are understandable by computers. To do this, PVM has interpreter. Interpreter is responsible for converting byte-code to machine-oriented codes.
MEMORY MANAGEMENT IN PYTHON
In Python, memory allocation are done during the runtime/ execution of a Python program. PVM usually is responsible for the allocation/ deallocation of objects. Everything is considered as objects in Python and for every objects memory should be allocated. Memory Manager inside the PVM allocates memory required for objects created in a Python program. All these objects are stored in separate memory space called heap space.
That’s all, see you in the next lecture.