CPython is bytecode interpreter?

后端 未结 3 1099
小蘑菇
小蘑菇 2020-12-03 02:10

I don\'t really get the concept of \"bytecode interpreter\" in the context of CPython. Can someone shed some light over the whole picture?

Does it mean that CPython

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 02:55

    CPython is the implementation of Python in C. It's the first implementation, and still the main one that people mean when they talk about Python. It compiles .py files to .pyc files. .pyc files contain bytecodes. The CPython implementation also interprets those bytecodes. CPython is not written in C++, it is C.

    The compilation from .py to .pyc happens transparently as needed. When you execute a .py file, it will first be compiled to a .pyc file if needed, then the .pyc file will be interpreted.

    Jython is different because (in addition to being implemented in Java instead of C) it compiles .py files into .class files so they can be executed in the JVM.

提交回复
热议问题