Python-learning mechanism of the two --Python notes, most people certainly not

 

 

Introduction to Python interpreter

  Let interpreter is a program running another program, which is the logical software layer between the computer hardware of the machine code, Python interpreter is a program that allows a Python program executed on the machine. 
When we execute Python code is written, Python interpreter performs two steps

  1. To compile source code into bytecode 
      bytecode compiler is a form specific to Python, it is not binary machine code, the compiler needs to be further executed by a machine, which is the Python code can not run like C / C ++ the reason as fast. If the Python process has write privileges on the machine, it will save the bytecode program is to .pyc as a file extension, if Python byte code can not be written on the machine, the bytecode will generating in memory and are automatically discarded at the end of the program. When building a program to best Python conferred on the authority to write on the computer, so long as the source code is not changed, the resulting file can be reused .pyc, improve the efficiency.
  2. Forwards compiled bytecode to Python virtual machine (PVM) for execution. In addition, if you are in python learning process. Do not understand the question, over and over again can exchange small series of Python dress: a long time and their weapons while under a stream of thought (digital homonym) conversion can be found, there are new Python Tutorial project, more exchanges with inside heavyweights. Progress will be faster!
      Python Virtual Machine PVM is short, it is the Python runtime engine, part of the Python system, which is a large loop iteration byte code instruction, one after another to complete the operation. 
    Python interpreter to run mechanism maps

Several versions of the Python interpreter implementation,

  There are three main Python interpreter implementations, CPython, the three ways the Jython and IronPython 
1. CPython 
  wherein CPython standard is implemented, there are other specific target. 
CPython is written in C, it is most Linux and Mac OS X machines pre-installed Python interpreter, but also all the Python interpreter to run the fastest, most complete and robust. 
The Jython 2. 
  the Jython is an alternative implementation of the Python language, its purpose is to integrate with the Java programming language, Jython include Java classes that compile Python source code, Java bytecodes are formed, and the resulting byte code mapped to the Java virtual machine (JVM) on. Because Jython slower than CPython but also robust enough, it is often seen as an interesting tool for Java developers looking for Java code for a major front-end scripting language. 
3. IronPython 
  purpose IronPython is designed to allow Python programs can be written in open source and Linux as well as on the .NET framework on Windows platforms corresponding to the Mono application integration.

Psyco-time compiler

  psyco system is not another Python implementation, but a component that extends Python bytecode execution module, which lets the program run faster. It is a PVM enhancement tools, and the tool used to collect information on the program is running, it may be converted into a part of the program bytecode true binary machine code underlying, enabling faster execution. In a development process, Psyco code without modification or separate compilation step to complete the conversion. 
  Generally speaking, when the program is run, the Psyco category information collected during the objects being passed, the type information can be used to cut the object so as to generate efficient machine code. Once generated machine code, to replace the corresponding original byte code, thus speeding up the overall program execution speed. Some optimized by Psyco Python code execution speed can be as fast as compiled C code. 
Since the bytecode conversion program running simultaneously, so often it is seen as a Pysco time compiler (JIT). Psyco is actually a proprietary JIT compiler: it generates machine code to streamline data type to the type of program you actually use. Also, if you are in python learning process. Do not understand the question, over and over again can exchange small series of Python dress: a long time and their weapons while under a stream of thought (digital homonym) conversion can be found, there are new Python Tutorial project, more exchanges with inside heavyweights. Progress will be faster!
  Psyco algorithm code is implemented in pure Python. This is especially important, in order to optimize those who often need to move to that part of the code C, after using Psyco, such migration is not necessary.

Guess you like

Origin www.cnblogs.com/chengxuyuanaa/p/12010553.html