2

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?).

I am talking about python of https://www.python.org/ interpreter. so the question is : what is python bytecode language ? C ? python ? ASM ? and what will execute this bytecodes in virtual machine ? is it a language ? and when it interpret this line , what are bytecodes likes ?

>>> print("HI")
HI

I also find this page : http://svn.python.org/view/

Zero Days
  • 851
  • 1
  • 11
  • 22
  • There is *a* Python interpreter written in C, but it's not the only one. This question is much too broad as it stands. – jonrsharpe Sep 13 '15 at 13:10
  • possible duplicate of [What is the difference between assembly code and bytecode?](http://stackoverflow.com/questions/1782415/what-is-the-difference-between-assembly-code-and-bytecode) – tripleee Sep 13 '15 at 14:59
  • The answers there aren't supremely excellent but it's fundamentally the same question. See also e.g. [this answer](http://stackoverflow.com/a/2203296/874188) to a similar question about Java. – tripleee Sep 13 '15 at 15:01

2 Answers2

2

Python bytecode is basically the instruction set of the Python virtual machine, its machine code, if you will.

Like the machine code used by CPUs like x86 and ARM, it is a "language" that is not meant to be human-readable. It is meant to be run efficiently.

The dis module acts like a "disassembler" converting the binary instructions into something human readable.

Roland Smith
  • 42,427
  • 3
  • 64
  • 94
1

to have an overview of bytecode, use dis module

Example:

def a():
    print("HI")

now :

import dis
dis.dis(a)

Then you show the byte-code.

Emmanuel DUMAS
  • 680
  • 10
  • 25