Python Road -01-python related concepts

Source: Internet
Author: User

1. What is the difference between compilation and interpretation?

Compiler: Each statement of the source program is compiled into a machine language , and saved as a binary file, so that the runtime computer can directly run the program in machine language, fast

Interpreter: only in the execution of the program, only one explanation of the machine language to the computer to execute, so the speed is not as fast as the compiled program to run

2. What are the differences between compiled and interpreted types?

Compiled type:

Pros: Compilers typically have pre-compiled procedures to optimize code. Because the compilation is done only once, the runtime does not need to compile, so the program execution of the compiled language is highly efficient. Can run independently from the language environment.
Cons: After compilation, the entire module needs to be recompiled if modifications are required. Compile the machine code according to the corresponding operating environment, porting between different operating systems will be problematic, you need to build different executables according to the operating system environment.

Explanatory type
Pros: Good platform compatibility, can be run in any environment, provided the interpreter (virtual machine) is installed. Flexible, modify the code when the direct modification can be quickly deployed, without downtime maintenance.

Cons: Every time you run, you have to explain it again, performance is not as good as the compiled language

3. Strong type definition language and weak type definition language?

Strongly typed definition language: a language that enforces the definition of a data type. In other words, once a variable is assigned a data type, it is always the data type if it is not cast. For example: If you define an integer variable A, the program simply cannot treat a as a string type. Strongly typed definition language is a type-safe language

weak type definition language: A language in which data types can be ignored. In contrast to strongly typed definition languages , a variable can assign values of different data types.

strongly typed definition language may be slightly slower than weak type definition language, but the rigor of strong type definition language can effectively avoid many errors. In addition,"The language is not a dynamic language" and "whether the language is type-safe" is completely no connection between

Summary:Python is a dynamically explanatory, strongly typed definition language

    1. Python pros and cons

Advantages: 1.Python positioning is "elegant", "clear", "simple" 2. the development efficiency is very high, Python has a very powerful third-party library 3. high-level language ———— when you write programs in the Python language, you don't have to consider the underlying details such as how to manage the memory used by your program

portability ———— because of its open source nature, Python has been ported on many platforms

Scalability ———— If you need a piece of your critical code to run faster or you want some algorithms to be private, you can write some of your programs in C or C + + and then use them in your Python program

embeddable ———— You can embed python in your C + + program to provide scripting capabilities to your program users

Cons: 1. Slow, Python runs slower than C and is slower than Java (with tool testing,) 2. The code cannot be encrypted (available c+ write, then call) 3. threads cannot take advantage of multiple CPU problems, which is one of the most common drawbacks of Python, Gil, the Global Interpreter lock (interpreter lock), is the tool that the computer programming language interpreter uses to synchronize threads . So that at any moment only one thread is executing,the python thread is the native thread of the operating system

5.python Interpreter

1.CPython: When we download and install Python 2.7 from the official Python website, we get an official version of the interpreter: CPython. This interpreter was developed in C language, so called CPython. Running Python at the command line is starting the CPython interpreter

2.ipython:ipython is an interactive interpreter based on CPython, meaning that IPython is only enhanced interactively, but the functionality and CPython of executing Python code are exactly the same. Like many domestic browsers although the appearance of different, but the kernel is actually called ie.

CPython with >>> as a prompt, while ipython in [serial number]: as a prompt

3.pypy:pypy is another Python interpreter whose goal is to perform speed. PyPy uses JIT technology to dynamically compile Python code (note that it is not interpreted), so it can significantly improve the execution speed of Python code.

4.Jython

Jython is a Python interpreter running on the Java platform that compiles python code directly to Java bytecode execution

5.IronPython

IronPython is similar to Jython, except that IronPython is a Python interpreter running on the Microsoft. NET platform that compiles python code directly into. NET bytecode

Summary: Python has a lot of interpreters, but the most widely used is cpython. If you want to interact with the Java or. NET platform, the best approach is not to use Jython or IronPython, but to interact via network tuning to ensure the independence of each program

Python Road -01-python related concepts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.