CPython是字节码解释器? [英] CPython is bytecode interpreter?

查看:165
本文介绍了CPython是字节码解释器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CPython的上下文中并不真正得到字节码解释器的概念。有人可以在整张图片上留下一些光吗?

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

这是否意味着CPython将编译和执行pyc文件(字节码文件?那么什么编译py文件到pyc文件呢? Jython与CPython的不同之处(除了它们是用不同的语言实现的)。

Does it mean that CPython will compile and execute pyc file (bytecode file?). Then what compile py file to pyc file? And how is Jython different from CPython (except they are implemented in different languages).

我也读过Python是C ++的解释。它是否正确?这是什么意思?

I also read somewhere that Python is C++ interpretation. Is this correct? And what does that mean?

我还是Python的新手,所以原谅我,如果我问愚蠢的问题...
谢谢你!

I'm still very new to Python, so forgive me if I ask the dumb questions... Thank you so much!

推荐答案

CPython是C的Python实现。这是第一个实现,谈论Python。它将.py文件编译为.pyc文件。 .pyc文件包含字节码。 CPython实现也解释那些字节码。
CPython不是用C ++编写的,它是C。

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.

从.py到.pyc的编译是根据需要透明地进行的。

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是不同的,因为(.py文件会被解释。除了用Java而不是C实现)它将.py文件编译成.class文件,以便它们可以在JVM中执行。

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.

这篇关于CPython是字节码解释器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆