Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python bytecode, the interpreter and virtual machine

This is a really vast question and I'm mostly looking for resources where I can learn more about the following.

I know the python interpreter is written in C and produces bytecode to be run on the python virtual machine also written in C (right?). My question is would it be possible to implement both of these in python itself? I guess where I'm going with this is the (technical) possibility of writing something like on OS in python, particularly WITHOUT statically compiling anything?

If I understand correctly, python doesn't have an assembler which would have to be written as well in python. Are these things something that could technically (feasibly?) be done? Or would the dynamic typing of python pose some kind of problem?

I know a bit about microprocessor architecture, assembly and machine code, what a recent EE grad learns in school. But I get lost looking at the whole picture for higher level languages like python.

like image 684
Falmarri Avatar asked Nov 10 '10 18:11

Falmarri


People also ask

Is Python interpreter a virtual machine?

Step 3: Byte code is then sent to the Python Virtual Machine(PVM) which is the python interpreter. PVM converts the python byte code into machine-executable code.

What is a bytecode in Python?

Bytecode is an intermediate language for the Python virtual machine that's used as a performance optimization. Instead of directly executing the human-readable source code, compact numeric codes, constants, and references are used that represent the result of compiler parsing and semantic analysis.

What is bytecode and virtual machine?

Bytecode is computer object code that an interpreter converts into binary machine code so it can be read by a computer's hardware processor. The interpreter is typically implemented as a virtual machine (VM) that translates the bytecode for the target platform.

Does virtual machine run bytecode?

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation.


1 Answers

Compiler, not interpreter. But you're looking for PyPy.

like image 91
Ignacio Vazquez-Abrams Avatar answered Sep 21 '22 00:09

Ignacio Vazquez-Abrams