Python Basic python Introduction

Source: Internet
Author: User

Python Introduction

Python (United Kingdom pronunciation:/?pa?θ?n/American pronunciation:/?pa?θɑ?n/) is an object-oriented, interpretive computer programming language , Guido van Rossum from the Dutch. invented in 1989, during the Christmas of 1989, in Amsterdam, Guido was determined to develop a new script interpreter, as an inheritance of the ABC language, in order to get rid of the boredom of Christmas. Python was chosen as the name of the programming language because he was a fan of the comedy community called Monty Python. The first public release was released in 1991.

Python has a rich and powerful library. It is often nicknamed the Glue language and is able to easily connect a variety of modules made in other languages, especially in C + +.

currently Python's main areas of application:

Cloud computing : The hottest language in cloud computing, typical application OpenStack

L Web Development : A number of excellent web frameworks, many large sites are Python development, Youtube, Dropbox, watercress ... , a typical web framework has Django

L Scientific Computing, artificial intelligence : Typical library numpy, SciPy, matplotlib, Enthought Librarys,pandas

L System Operation and maintenance: the necessary language for operation and maintenance personnel

L Finance : Quantitative trading, financial analysis, in the field of financial engineering,Python is not only used, and used the most, 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 calculation and statistical analysis are very good, production efficiency is much higher than c,c++,java, especially good at strategy backtesting

L graphical gui: PyQT, Wxpython,tkinter

What is the difference between compilation and interpretation?

compiler is to compile each statement of the source program into a machine language and save it as a binary file so that the computer can run the program directly in machine language at a very fast speed.

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

This is because the computer does not directly recognize and execute the statements we write , it only knows the machine language (in binary form)

Dynamic language and static language

Dynamic Type language: A dynamic type language is a language that does not perform data type checking during run time. in use when programming a dynamically typed language, you never have to specify a data type for any variable . the language will record the data type internally when you assign it to a variable for the first time .

Static type language: The static type language is exactly the opposite of the dynamic type language, and its data type is checked during compilation, The data type is checked during compilation, which means that the the data type of all variables to be declared when the program is written.

Strongly typed 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.

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.

Python is a dynamic language and is a strongly typed definition language (type-safe language)

Python pros and cons

Advantages:

    1. Python's positioning is "elegant", "clear", "simple", so the Python program looks always easy to understand, beginners learn python, not only easy to get started, but also in the future, you can write those very very complex programs.
    2. Very high development efficiency , Python has a very powerful third-party library , basically you want to achieve any function through the computer,the Python official library has the corresponding modules to support, directly download the call, on the basis of the base library to develop, greatly reduce the development cycle, to avoid repeating the wheel.
    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
    4. portability ———— because of its open source nature, Python has been ported on many platforms (modified to make it work on different platforms). If you are careful to avoid using system-dependent features, all your Python programs can run on almost any system platform on the market without modification
    5. 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.
    6. embeddable ———— You can embed python into your C + + program to provide scripting functionality to your program users.

Disadvantages:

1. Slow running: This is compared to C and C + +.

2. Code cannot be encrypted , because Python is an explanatory language, and its source code is stored in the form of a famous text.

3. threads cannot take advantage of multi- CPU issues

Python Interpreter

CPython is a The most widely used Python interpreter. All the code for the tutorial is also executed under CPython.

( Default Interpreter )

IPython

Ipython is only enhanced in interactive mode, but the function of executing Python code is exactly the same as CPython.

CPython uses >>> as a prompt, while Ipython uses in [ordinal]: as a prompt.

PyPy

PyPy but PyPy and CPython are somewhat different, which leads to the same Python code being executed under both interpreters with different results.

Adopt JIT technology , Dynamic compilation of Python code (note is not interpreted), so you can significantly improve the execution speed of Python code

Jython

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

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's Running process

before we say this question, let's start with two concepts, Pycodeobject and the PYc File .

The PYc we see on the hard drive naturally doesn't have to say much, and pycodeobject is actually the result of a Python compiler actually compiling it. Let's just get to the bottom of it and keep looking down.

When the Python program runs, the result of the compilation is saved in the pycodeobject in memory , and when the Python program finishes running, the Python interpreter will Pycodeobject writes back to the pyc file .

when the Python program runs for the second time, the program will first look for the PYc file on the hard disk, and if it is found, load it directly or repeat the process.

so we should be positioning ourselves like this. Pycodeobject and PYc files, we say that specifying the interpreter PYc file is actually a way to persist the pycodeobject.

Python Basic python Introduction

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.