Chapter python how to run the program

A .python interpreter introduced

Python interpreter is a way for the program up and running program . In fact, a logical explanation is a software layer between the computer hardware of the machine code.
When the Python package installed on the machine, which contains a number of components is minimized: an interpreter and supporting libraries .

Two .python perspective

When running Python scripts, the first step is to compile your code into a "byte code" , and then forwards it to the so-called "virtual machines" .

Step 1: bcompiler

When the program executes, Python will first internal source (statement file) into a compiled form called bytecode. Compile a simple translation step, the source code and byte code underlying platform-independent representation. In summary, Python to translate these statements into the source code instructions by a group of bytes each of the source statement into a single step. These bytecode execution speed can be increased.

That is, the extension is .pyc file -> file name suffix .py's.

Such Python code is stored as a byte start speed optimization. The next time you run the program, if you have not modified the source code since the last save, then bytecode, Python will load the file and skip the compilation .pyc this step.

2. Step two: python virtual machine (pvm)

Once the program is compiled into bytecode (or bytecodes .pyc loaded from the file already exists), then the bytecode is sent to the virtual machine commonly referred Python (Python Virtual Machine, abbreviated as PVM) up execution. Technically, it is the so-called "Python interpreter," the last step.

3. Performance of meaning

Python work usually does not "build" or "make" step: write code to run immediately after. Another is, Python byte code is not binary machine code (eg, Intel chip instruction). Bytecode is specific to a form of Python.
This is why as fast as Python code can not be run like a C or C ++ code.

 

 From a more fundamental perspective, keep in mind that only runs when we really have in Python: totally do not need to compile the initial phase, all things are handled at run-time. This even includes the operation of functions and classes and means to establish connection. These things tend to be static language occurs before the execution, but in Python with the execution of the program is carried out at the same time. As we have seen, the actual effect is to bring a more dynamic Python programming language readers experience than some of the procedures used.

4.CPython

The original, Python standard implementations commonly referred CPython. Figure 2-2 reflects the operational architecture of CPython.

5.Jython

Jython include Java classes that compile Python source code, Java bytecodes are formed, and the resulting byte code mapped onto the Java Virtual Machine (JVM). Programmers can still be as usual, write Python statement in a text file; the nature of Jython system is to replace the contents of Figure 2-2 rightmost two boxes for the equivalent Java-based implementation.

6.IroPython

It replaces the last two blocks of FIG. 2-2, which was replaced by an equivalent implementation of the .NET environment.

 

Guess you like

Origin www.cnblogs.com/happytongtong/p/11098514.html