TZH, Python theory (i)

Source: Internet
Author: User

Directory

    • The history of Python
    • Python's main areas of application
    • What kind of language is Python?
    • The pros and cons of Python
    • Python interpreter

Text One, the history of Python
  • Python's founder is "Guido van Rossum (Guido van Rossum)", 1989 Christmas, in order to pass time in Amstant, began to write the Python language compiler, the name Python, from Guido Love TV series (Monty Python ' s Flying circus.) Create a language that is versatile, easy to learn, easy to use, and extensible between C and Shell.
  • 1991, the first Python compiler was born, is implemented in C language, and can call the C language library file, from the birth, Python already has: classes, functions, exception handling, including tables and dictionaries, core data types, as well as module-based extensions and systems.
  • Granddaddy of Python Web frameworks, Zope 1 is released in 1999
  • Python 1.0-january 1994 adds lambda, map, filter and reduce
  • Python 2.0-october 16, 2000 adds a memory recovery mechanism that forms the basis of the Python language framework Now
  • Python 2.4-november 30, 2004 the same year now the most popular web framework Django was born
  • Python 2.5-september 19, 2006
  • Python 2.6-october 1, 2008 (compatible with 2.4 and 3.0 versions)
  • Python 2.7-july 3, 2010 (compatible with 2.4 and 3.0 versions)
  • In November, it is announced that Python 2.7 would is supported until 2020, and reaffirmed that there would is no 2 .8 release as users were expected to move to Python 3.4+ as soon as possible (in November 2014, announced that Python 2.7 would be supported to 2020, and reiterated that there would not be 2.8 releases, Because the user is expected to move to Python 3.4 + as soon as possible. )
  • Python 3.0-december 3, 2008 (completely incompatible with the then mainstream 2.4 version)
  • 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, Python's main areas of application
    • Cloud computing: The hottest language in cloud computing, typically using OpenStack
    • Web development: A number of excellent web frameworks, many large sites are Python development, Youtube, Dropbox, watercress ..... A typical web framework has Django
    • Scientific computing, Artificial intelligence: Typical library NumPy, SciPy, Matplotlib, Enthought Librarys, pandas
    • System operation and maintenance: the necessary language for operation and maintenance personnel
    • Finance: Quantitative trading, financial analysis, in the field of financial engineers, Python is not only used, and the most used, but also the importance of increasing year by year, 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, production efficiency far Much higher than C, C + +, Java; Especially good at strategy backtesting.
    • Graphic GUI:PYQT, WxPython, Tkinter

Third, what kind of language is Python?

  Programming language is mainly divided into: compiled and interpreted type; Static language and dynamic language; Strong type definition language and weak type definition language.

Python is a "dynamic-interpreted strongly typed definition language"

    • Compile-and-interpret
      • Compiler : Responsible for translating the program to the whole of our source code conversion, generate the corresponding executable code, called "Compilation (Compile)", is responsible for compiling the program is called "Compiler (Compiler)", the advantage of the program execution speed, Under the same conditions, the system requirements are low, the development of operating systems, large applications, database systems, such as using it, such as C + +, VB, etc.
      • Explanatory : A language that uses a specialized interpreter to interpret the source program on a per-line basis into a machine of a particular platform and execute it immediately; Interpreted languages generally do not compile and link in a holistic way, and interpreted languages are equivalent to mixing compilation and interpretation processes together in a compiled language. Advantages for cross-platform is relatively easy, only need to provide a specific platform of the interpreter, to facilitate the migration of the source program. Web scripts, server scripts, and auxiliary development interfaces This is not a requirement for speed, and programs that have certain requirements for compatibility with different system platforms often use interpreted languages such as Java, JavaScript, VBScript, Perl, Python, etc.
    • Dynamic language and static language
      • Dynamic Type language : The language of data type detection during run time, that is, when programming in a dynamic type language, you never have to specify a data type for any variable, and the language will record the data type internally when you assign it to a variable for the first time, and Python and Ruby are A typical dynamic type language;
      • Static type language : Its data types are detected during compilation, that is, the data types of all variables are declared at the time of writing, C/C + + is represented by statically typed languages, and Java is a static type language.

    • Strongly typed definition language and weak type definition language
      • strongly typed language : a language that enforces the definition of a data type; That is, once a variable is assigned a data type, and if it is not cast, it will always be the original defined data type, for example: Define an Integer variable A, then Cheng is not possible to use variable A As string processing, strongly typed definition language is a type-safe language;
      • Weakly typed language : a language in which data types can be ignored, and in contrast to strongly typed definition languages, a variable can assign values of different data types.
      • The difference: Strongly typed definition languages may be slower than weakly typed languages, but strong type definition language rigor can effectively avoid many errors.
Iv. advantages and disadvantages of Python
  • Benefits
    • python structure "elegant", "clear", "simple"; so the Python program looks simple and easy to understand, beginners learn python, it's easy to get started, and later in depth, you can write very complex programs;
    • development efficiency is very high, Python has a very powerful third-party library, basically you want to achieve through the computer any function, the Python official library has the corresponding module to support, directly download the call, on the basis of the base library to develop again, greatly reduce the development cycle, to avoid repeating the wheel; /li>
    • High-level language, when you write a program in the Python language, you do not have to consider how to manage the program to use memory class of the underlying details;
    • Portable, Python-based open source nature, has been ported on many platforms (modified to work on different platforms), if you carefully avoid the use of system-dependent features, then all of the Python program without modification can be almost on the market all the system platform to run;
    • extensible, if a piece of critical code in your code wants it to run faster or you want some algorithms to be private, you can write it in C or C + + and then use it in a Python program;
    • The
    • can be embedded to embed python in a C + + program and to provide scripting functionality to the program user.
  • Disadvantages
    • Slow, Python run faster than C is really slow, and Java compared to a bit slower, in fact, this is said to run slowly in most cases the user is not directly aware of, must rely on testing tools to reflect; In most cases, Python is fully capable of meeting the speed requirements of the program, unless it is written to a search engine with very high speed requirements;
    • Code is not encrypted, because Python is interpreted language, its source code is stored in clear-text form; Can not be considered a disadvantage,
    • The thread does not take advantage of CPU problems, which is one of the most common drawbacks of Python, the GIL global interpreter lock, which is a computer programming language interpreter for synchronizing online Tool, so that at any moment only one thread is executing, and the Python thread is the native thread of the operating system, on Linux for Pthread, on Windows for Win thread, fully executed by the operating system scheduler thread, A Python interpreter process has a main thread, as well as a number of user program execution threads, even on the multi-core CPU platform, due to the existence of the Gil, so the parallel execution of multithreading is prohibited;
Five, Python interpreter

When you write code in Python, you get a text file with a. py extension that contains Python code, and to run the code, you need the Python interpreter to execute the. py file.

Since the entire Python language is open source from spec to interpreter, it is theoretically possible for anyone to write a Python interpreter to execute Python code (very difficult), as long as the level is high enough, in fact there are many Python interpreters.

  • CPython
    • After downloading and installing Python 2.7 from the Python website, get an official interpreter directly: CPython. This interpreter was developed using the C language, so called CPython, running Python under the command line is the start of 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 interactively, but the function of executing Python code is exactly the same as CPython, as many domestic browsers look different, But the kernel is actually called IE,
      CPython use ">>>" as a prompt; and Ipython with in [serial number]: as a prompt.
  • PyPy (target is fast execution speed)
    • PyPy is another Python interpreter whose goal is the speed of execution, pypy the use of JIT technology to dynamically compile Python code (note that it is not interpreted), so you can significantly improve the execution speed of Python code.
    • The vast majority of Python code can run under PyPy, but PyPy and CPython are somewhat different, which results in the same Python code being executed under both interpreters, and if your code is to be executed under PyPy, you need to know Different points of PyPy and CPython .
  • Jython
    • Jython is a Python interpreter running on the Java platform that can directly mutate the Python code into Java bytecode execution.
  • IronPython
    • IronPython is similar to Jython, except that IronPython is a Python interpreter running on the Microsoft. NET platform that can directly mutate the Python code into. NET bytecode.
  • Interpreter Summary
    • Python has a lot of interpreters, but the most widely used or CPython, if you want to and Java and. NET platform interaction, the best approach is not to use Jython or IronPython, but to interact via network tuning to ensure the independence of each program.

TZH, Python theory (i)

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.