python basis (1): python introduction, python development history

Introduction 1. python

1.1 python is what kind of language

Programming your language and get accustomed mainly from the following two ⻆ into ⾏ degree of classification, compiled and interpreted, static and dynamic your language and Language, strongly typed and weakly typed your language and definitions Language, we look at your language and compiled and interpreted your language and type. Besides the type of strong and weak type later

 

What is the difference between compiled and interpreted?

The compiler is the source of every ⼀ statements are compiled into machine Language, and save it as ⼆ binary files, computer directly to the machine to your language and when running a program when running a time like this, very fast.

When ⽽ interpreter is only in YES program, only ⼀ Articles of ⼀ your language and interpreted into machine to the computer to Perform, so when running a program after the speed is not as good as when running a compilation of the fast.

This is because the computer can not directly recognize and YES we write the statement, it can only recognize your language and machine (a ⼆ hexadecimal format).

 

 

Compiled vs interpreted

Compiled

Pros: The compiler shoots as usual there will be pre-compiled code into ⾏ process optimization. Because the compiler only ⼀ times, you do not need when running a compile-time, so your language and compiled programs Perform efficiency ADVANCED. Your language and can be detached when running a separate environment.

Cons: After compiling If you need to modify the entire module needs to be recompiled. The compile time environment when running a corresponding ⽣ into machine code, there will be migration problems between different operating systems, the need to compile the environment when running a different operating system files may be YES.

Interpreted

Pros: Good platform compatibility in any environment when running a can, provided that the interpreter (Virtual Machine) installed. Flexible and modify the code directly modify when you can, you can quickly deploy, will not be used down for maintenance.

Cons: every time when running a must explain ⼀ times, as compiled your language and performance.

1.2 python advantages and disadvantages

Look at the advantages:

1. Python position is "elegant" and "clear", "simple", so Python program always looks easy to understand for beginners to learn Python, not only ⻔ easily START on it and the future START deep down, you can write that comes in handy complex procedures often comes in handy.

2. ADVANCED development efficiency comes in handy, Python third ⽅ library comes in handy strong zoomed in, you basically want to achieve through any computer functions, Python official ⽅ library ⾥ has a corresponding module into ⾏ ⽀ hold, directly after the download transfer Use , on the basis of the library based on the charge before development, zoomed zoomed reduce the development cycle, to avoid duplication wheel made submenus.

3. ADVANCED your language and ---- When you program your language and written in Python Use, No need for you to consider, such as how to manage your program so that low-level details of memory ⼀ class Use

4. Portability ---- because of its open-source nature, Python has been ported on many platforms (changed to make it ⼯ made on different platforms). If you avoid CAUTION Using the system-dependent features, then all your Python programs No need for modification can get accustomed Operation with almost all the platforms on the market

5. Scalability ---- If you want your one Hash key codes when running a very fast or want some algorithms are not open, you can put part of your program Using C or C ++, then in your Python programs Using their manipulation.

6. can be embedded START of ---- you can embed Python clicks into your C / C ++ program that provides scripting capability to your program from ⽽ Use households.

Look Cons:

1. slow, Python's speed when running a C phase ⽐ your language and indeed much slower, with JAVA phase ⽐ needs to slow ⼀ more, so this is a lot of so-called zoomed ⽜ bothered to make the main reason for Using Python, but in fact individual cases from within the meaning of the slow speed when running a zoomed in most cases the user is ⽆ Using direct perceived need help with testing ⼯ can be reflected, as you ⽐ Using C transport ⼀ programs took 0.01s, 0.1s Using Python is so C your language and Python directly ⽐ 10 times faster, be an exaggeration comes in handy, but you are ⽆ law directly through ⾁ eye perceives, because ⼀ Face can perceive normal time most ⼩ unit is about 0.15-0.4s , ha ha. In fact, in most situations is full Python has been completely underexposed you can speed requirements of the program, in addition comes in handy for you to write to extremely high speed requirements of search engines, in which case, of course, it is recommended that you go Using the C implementation.

2. The code can not be encrypted because PYTHON interpretative Language, its source code is stored in the form of the name of the file, but I do not think it ⼀ be a disadvantage if the item you requested your source code must be encrypted, that you should not start ⼀ Using Python come to realize.

3. Using the multiple CPU threads can not benefit issue, this is Python is the most criticized ⼀ Face disadvantage, GIL namely the global interpreter lock (Global Interpreter Lock), is a computer programming your language and an interpreter Use to synchronize threads to work surely has, so that any time only ⼀ threads in YES, Python threads are original ⽣ operating system threads. On Linux is pthread, on Windows Winthread, entirely by the operating system thread scheduling YES. There ⼀ strip the main thread, and the thread Perform Using multiple user program within ⼀ a python interpreter process. Even on multi-core CPU platform, because of the GIL, it is prohibited multithreading and ⾏ YES. On the subject of compromise Remedies, we ⾥ discussed in detail at a later charge before threads and processes chapters.

Of course, Python as well as other ⼩ ⼀ some shortcomings, this is not ⼀ ⼀ lists, I want to say is, whichever is ⻔ your language and are not perfect, there are good at and not good ⻓ ⻓ things to do, it is recommended you do not take a ⼀ your language and disadvantages to talk for another time advantage of your language and come and go ⽐ than, your language and just ⼀ with a ⼯, is thought to work surely achieve programmers tools, just like before when we get accustomed secondary school , sometimes need to compasses, sometimes need ⻆ Using three feet ⼀ like, take appropriate to work surely has to do something it had been masters ⻓ is the right choice.

1.3 python interpreter

When we write Python code, we get a ⼀ files containing Python code files with this extension of .py. To when running a code, you need Python interpreter to Perform .py files. Since the entire Python from specification to your language and interpreter are open source, so in theory, as long as enough ADVANCED Horizontal, Face can write any Python interpreter to Perform Python code (of course, very difficult zoomed). In fact, the existence of multiple Python interpreter.

CPython

When we download and install Python3.6 from Python official website for ⽅, we have direct access to the ⼀ a ⽅ official version of the interpreter: CPython. Using the interpreter C is your language and the development of so called CPython. At the command ⾏ when running a python it is to start CPython interpreter.

Using the most CPython is the full wide Python interpreter. All tutorials are also in the code under CPython YES.

IPython

IPython is based on one of CPython ⼀ interactive interpreter, that is to say, just IPython has been enhanced on the interactive mode, which is however Perform Python code is fully functional and CPython ⼀ like. Good ⽐ many domestic browser, although different appearance, but the kernel are actually tune Using the IE.

Use as CPython >>> prompt, ⽽ IPython Use In [ID]: as a prompt.

PyPy

PyPy is for another time Python interpreter, its destination time is marked Perform speed. PyPy recorded using JIT techniques for Performing Dynamic compiler Python code (note not explained), it is possible to significantly improve speed YES ADVANCED Python code.

Absolutely part of Python code can be zoomed Operation with under PyPy, but CPython have ⼀ PyPy and some are different, which leads to Perform the same Python code may have different results in the two interpreter. If you are under the code to put PyPy YES, we need to understand the different points of PyPy and CPython.

Jython

Python is Jython when running a Java interpreter on the platform, can be directly Python code is compiled into Java bytecode YES.

IronPython

IronPython and Jython similar, but IronPython is Operation with Microsoft's .Net platform Python interpreter, the Python code can be directly translated into .Net byte code.

2. History of python development

In 1989, in order to pass the Christmas holidays, Guido (⻳ t) began to write Python your language and compiler. Python name to automatically Guido beloved TV series Monty Python's Flying Circus. He hoped that the new language you called Python, able to meet his ideal: to create ⼀ kind between C and shell, ⾯ full-featured, easy to learn and use, be scalable language you want.

In 1991, the first frame a Python compiler birth ⽣. Use your language and it is the C implementation, and can be adjusted Using Library files of your language and C. From the ⽣ ⼀, Python already has: classes, functions, exception handling, Center Weighted core data types, including tables and dictionaries, and a module-based expansion system.

Granddaddy of Python web frameworks, Zope 1 was released in 1999

Python 1.0 - January 1994 increased by lambda, map, filter and reduce.

Python 2.0 - October 16, 2000, filling with the memory recovery mechanism, form the basis of your language and Python frameworks now

Python 2.4 - November 30, 2004, the same year the destination time before most streams perform while the WEB framework Django Festival ⽣

Python 2.5 - September 19, 2006

Python 2.6 - October 1, 2008

Python 2.7 - July 3, 2010

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

Python 3.0 - December 3, 2008

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

Guess you like

Origin www.cnblogs.com/liuhui0308/p/11788887.html