美文网首页
python 编译和解释流程

python 编译和解释流程

作者: ThomasYoungK | 来源:发表于2019-04-23 15:39 被阅读0次

Let's summarize what happens behind the scenes.
When a Python executes a program, Python reads the .py into memory, and parses it in order to get a bytecode, then goes on to execute. For each module that is imported by the program, Python first checks to see whether there is a precompiled bytecode version, in a .pyo or .pyc, that has a timestamp which corresponds to its .py file. Python uses the bytecode version if any. Otherwise, it parses the module's .py file, saves it into a .pyc file, and uses the bytecode it just created.

Byte code files are also one way of shipping Python codes. Python will still run a program if all it can find are.pyc files, even if the original .py source files are not there.

Python Virtual Machine (PVM)

Once our program has been compiled into byte code, it is shipped off for execution to Python Virtual Machine (PVM). The PVM is not a separate program. It need not be installed by itself. Actually, the PVM is just a big loop that iterates through our byte code instruction, one by one, to carry out their operations. The PVM is the runtime engine of Python. It's always present as part of the Python system. It's the component that truly runs our scripts. Technically it's just the last step of what is called the Python interpreter.

参考资料
Yogesh Chaurse Python Developer
https://www.quora.com/Is-Python-compiled-or-interpreted-or-both

相关文章

  • python 编译和解释流程

    Let's summarize what happens behind the scenes.When a Pyt...

  • python面试答题笔录

    1.简述解释型和编译型编程语言 解释型语言是指逐行读取解释代码,不用进行编译,它们有专门的解释型工具,python...

  • Python面试题合集

    Python基础 1. 简述解释型和编译型编程语言?解释型语言编写的程序不需要编译,在执行的时候,专门有一个解释器...

  • 基础概述

    基础 语言分类 编译型 : c,c++ Java 有编译型,也有解释型 解释型: Python,Rub...

  • 浅析Python解释器的设计(二)

    从现代编译器的角度看,解释器和编译器的边界已经相当的模糊。我们后面的讨论说到的编译器就是Python的解释器,没有...

  • Python笔记

    人生苦短,我用Python 编译器:解释器 编译器 Python属于解释型语言,读取一行,翻译一行,执行一行。 ...

  • Python学习-基础1

    python 解释性的脚本语言:直接执行,不需要编译 C 编译型语言:先编译,再执行 python特性: 内部机制...

  • 程序执行流程

    图解执行流程.png 注意严格来说 Python 是 先编译成字节码,然后再 解释执行 的一门语言.pyc 文件的...

  • 树莓派上python和C语言编程

    一、Python编程简介: Python是一种解释型语言,无语编译。Python具有丰富和强大的库。它常被昵称为胶...

  • 老司机教你如何跨进Python的大门

    1. Python介绍 python = 动态语言java = 静态语言python不用编译,直接解释执行,不用像...

网友评论

      本文标题:python 编译和解释流程

      本文链接:https://www.haomeiwen.com/subject/xvgvgqtx.html