TZH , Python Theory (1)

content


 

  • The history of python
  • The main application areas of python
  • what kind of language is python
  • Advantages and disadvantages of python
  • python interpreter

 

text


 One, the development history of python

  • The founder of python is "Guido van Rossum". During Christmas 1989, in order to pass the time in Amsterdam, he began to write a compiler for the Python language. The name of Python comes from Guido Beloved TV series (Monty Python's Flying Circus.) Create a full-featured, easy-to-learn, extensible language between C and the Shell.
  • In 1991, the first Python compiler was born, which was implemented in C language and was able to call C language library files. Since its birth, Python has already had: classes, functions, exception handling, including tables and dictionaries. Core data types, and module-based extensions and systems.
  • Granddaddy of Python web frameworks , Zope 1 was released in 1999
  • Python 1.0 - January 1994 added lambda, map , filter and reduce
  • Python 2.0 - October 16, 2000 added a memory recycling mechanism, which forms the basis of the current Python language framework
  • Python 2.4 - November 30, 2004 The most popular WEB framework Django was born in the same year
  • Python 2.5 - September 19 , 2006
  • Python 2.6 - October 1, 2008 (compatible with versions 2.4 and 3.0)
  • Python 2.7 - July 3, 2010 (compatible with versions 2.4 and 3.0)
  • In November 2014, it was announced that Python 2.7 would be supported until 2020 , and reaffirmed that there would be no 2.8 release as users were expected to move to Python 3.4+ as soon as possible (in November 2014, it was announced that Python 2.7 would be is supported until 2020, and reiterates that there will be no 2.8 release as users are expected to move to Python 3.4+ soon.)
  • Python 3.0 - December 3, 2008 (completely incompatible with the mainstream 2.4 version at the time)
  • Python 3.1 - June 27 , 2009
  • Python 3.2 - February 20 , 2011
  • Python 3.3 - September 29 , 2012
  • Python 3.4 - March 16 , 2014
  • Python 3.5 - September 13 , 2015

 

Second, the main application areas of python 

  • Cloud computing: the most popular language for cloud computing, typical application of OpenStack
  • WEB development: Many excellent WEB frameworks, many large websites are developed in Python, Youtube , Dropbox , Douban.....Typical WEB frameworks are Django
  • Scientific computing, artificial intelligence: typical libraries NumPy , SciPy , Matplotlib , Enthought libraries, pandas
  • System operation and maintenance: a necessary language for operation and maintenance personnel
  • Finance: quantitative trading, financial analysis, in the field of financial engineers, python is not only used, but also the most used, and its importance is increasing year by year, the reason: as a dynamic language Python, the language structure is clear and simple, the library is rich, mature and stable, scientific computing and statistical analysis are very good, the production efficiency is much higher than C, C++, java; especially good at strategy backtesting.
  • Graphical GUI: PyQT, WxPython, Tkinter

 

Third, what kind of language is python?

  Programming languages ​​are mainly divided into: compiled and interpreted; static and dynamic languages; strongly typed and weakly typed languages.

  Python is a "dynamically interpreted strongly typed language"

  • Compiled and Interpreted

    • Compiler type : The program responsible for translation converts our source code as a whole and generates the corresponding executable code, which is called "Compile", and the program responsible for compiling is called "Compiler". The advantage is that the program execution speed is fast, and the system requirements are lower under the same conditions. It is used in the development of operating systems, large-scale applications, database systems, etc., such as C/C++, VB, etc.
    • Interpreted : A language that uses a special interpreter to interpret the source program line by line into a machine of a specific platform and executes it immediately; Interpreted languages ​​usually do not perform overall compilation and linking processing, and interpreted languages ​​are equivalent to compiling languages. The compiling and interpreting processes are mixed together and completed at the same time. The advantage is that it is easier to cross-platform, only need to provide an interpreter for a specific platform, which is convenient for the porting of source programs. Web scripts, server scripts and auxiliary development interfaces do not require speed. Programs that have certain requirements for compatibility between different system platforms usually use interpreted languages, such as java, javaScript, VBScript, Perl, Python, etc.
  • Dynamic and static languages

    • Dynamically typed language : a language that does data type checking at runtime, that is, when programming in a dynamically typed language, you never have to assign a data type to any variable, the language will be the first time you assign to a variable , records the data type internally, Python and Ruby are a typical dynamically typed language;
    • Statically typed language : Its data type is detected during compilation, that is to say, the data type of all variables must be declared when writing a program. C/C++ is a representative of statically typed languages. C#, JAVA is also a statically typed language.

 

  • Strongly Typed Definition Language and Weakly Typed Definition Language

    • Strongly typed language : a language that enforces the definition of data types; that is, once a variable is assigned a data type, if it is not coerced, it will always be the originally defined data type, for example: define an integer variable A , Then it is impossible for Cheng Guanxi to treat the variable A as a string, and the strongly typed language is a type-safe language;
    • Weakly typed language : A language in which data types can be ignored. In contrast to strongly typed language, a variable can be assigned values ​​of different data types.
    • Difference: Strongly typed languages ​​may be slower than weakly typed languages, but the strictness of strongly typed languages ​​can effectively avoid many errors.

Fourth, the advantages and disadvantages of python

  • advantage

    • The python structure is "elegant", "clear" and "simple"; so the python program looks simple and easy to understand, beginners learn python, it is easy to get started, and later in-depth entry, you can write very complex programs;
    • The development efficiency is very high, python has a very powerful third-party library, basically any function you want to achieve through the computer, there are corresponding modules in the official python library to support, directly download and call, and develop again on the basis of the basic library , greatly reducing the development cycle and avoiding repeated wheel building;
    • High-level language, when you use python language to write programs, you don't need to consider the low-level details such as how to manage the memory used by the program;
    • Portable, based on the open source nature of python, it has been ported to many platforms (modified to work on different platforms), and if care is taken to avoid using system-dependent features, then all python programs can be almost Runs on all system platforms on the market;
    • Extensible, if a key piece of code in the code wants to make it run faster or some algorithms are not exposed, it can be written in C or C++, and then used in the python program;
    • Embeddable, you can embed python into C/C++ programs, and provide scripting functions to program users.
  • shortcoming

    • The speed is slow. The running speed of python is indeed much slower than that of C, and it is also slower than that of JAVA. In fact, the slow running speed mentioned here is not directly perceived by users in most cases, and it must be reflected by testing tools; In most cases, python can fully meet the requirements for program speed, unless writing a search engine that requires extremely high speed;
    • The code is not encrypted, because python is an interpreted language, and its source code is stored in plaintext; it may not be considered a disadvantage,
    • The problem that threads cannot use the CPU is one of the most criticized shortcomings of python. The GIL (Global Interpreter Lock) global interpreter lock is a tool used by computer programming language interpreters to synchronize online , so that only one thread is executing at any time. , The thread of python is the native thread of the operating system, which is pthread on Linux and Win thread on windows. The execution of the thread is completely scheduled by the operating system. There is one main thread in a python interpreter process, as well as multiple user programs. Execution threads, even on multi-core CPU platforms, because of the existence of the GIL, the parallel execution of multi-threads is prohibited; 

Five, python interpreter

  When writing code in python, you get a text file with a .py extension containing python code. To run the code, you need the python interpreter to execute the .py file.

  Since the entire python language is open source from the specification to the interpreter, theoretically, as long as the level is high enough, anyone can write a python interpreter to execute python code (very difficult), in fact, there are indeed a variety of python interpretations device.

  • CPython
    • After downloading and installing python 2.7 from the python official website, you can directly obtain an official interpreter: CPython. This interpreter is developed in C language, so it is called CPython. Running python on the command line is to start the CPython interpreter.
    • CPython is the most widely used Python interpreter.
  • IPython
    • IPython is an interactive interpreter based on CPython, that is to say, IPython is only enhanced in interactive mode, but the function of executing Python code is exactly the same as that of Cpython, just like many domestic browsers have different appearances, but The kernel actually calls IE,
      CPython uses ">>>" as the prompt; and IPython uses In [number]: as the prompt. 
  • PyPy (goal is fast execution)
    • PyPy is another Python interpreter whose goal is execution 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.
    • Most Python code can be run under PyPy, but PyPy and CPython are somewhat different, which leads to the same python code executing under the two interpreters may have different results, if your code is to be executed under PyPy , you need to understand the differences between PyPy and CPython .
  • Jython
    • Jython is a Python interpreter running on the Java platform, which can directly mutate Python code into Java bytecode for execution.
  • IronPython
    • IronPython is similar to Jython, except that IronPython is a Python interpreter running on Microsoft's .Net platform, which can directly mutate python code into .Net bytecode.
  • Interpreter Summary
    • There are many Python interpreters, but CPython is the most widely used. If you want to interact with Java and .Net platforms, the best way is not to use Jython or IronPython, but to interact through network calls to ensure the independence of each program. .

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324628549&siteId=291194637