Xiaobai must see! Advantages and disadvantages of Python

Python  is an object-oriented, interpreted, general and open source scripting programming language. The reason why it is very popular, I think there are three main reasons:

  • Python is easy to use, low cost of learning, and looks very elegant and clean;
  • Python standard library and third library are numerous and powerful, which can develop small tools and enterprise-level applications;
  • Python stands on the vent of artificial intelligence and big data . Standing on the vent, pigs can fly.


Give a simple example to illustrate the simplicity of Python. For example, to implement a certain function, C language may need 100 lines of code, while Python may only need a few lines of code, because C language has to start from scratch, and Python has built-in many common functions, we only need to import the package, and then Just call a function.

Simplicity is one of the great charms of Python. It is its killer feature. It is simply unbearable to use Python and then C language.

This article will summarize the features of Python and compare its advantages and disadvantages.

                                                                      Python resource group: 1156465813

Advantages of Python

1) Simple syntax

 Compared with the traditional C/ C++ , Java , C# and other languages, Python has less strict requirements on the code format. This looseness makes users more comfortable when writing code without spending too much energy on the details. Let me give two typical examples:

  • Python does not require a semicolon at the end of each statement, of course, it is correct;
  • There is no need to specify the type when defining a variable, and you can even assign different types of data to the same variable.


These two points are also   features of common scripting languages ​​such as PHP , JavaScript , and MATLAB .

Python is a programming language that represents minimalism. Reading a beautifully typed Python code is like reading an English paragraph, which is very close to human language, so people often say that Python is a programming language with pseudo-code characteristics.

Pseudo Code (Pseudo Code) is an algorithm description language, which is between natural language and programming language. The purpose of using pseudo code is to enable the described algorithm to be easily used in any programming language (Pascal, C, Java, etc) implementation. Therefore, pseudo-code must be clear in structure, simple in code, readable, and similar to natural language.

If you have studied data structures and read Yan Weimin's books, then you must know what pseudocode is.

Why is simplicity the killer? Once it is simple, one thing becomes very pure; when we develop Python programs, we can focus on solving the problem itself, without worrying about the details of the syntax. Doing a pure thing in a simple environment is simply a pleasure.

2) Python is open source

Open source, that is, open source, means that all users can see the source code.

The open source of Python is embodied in two aspects:

① The code written by programmers in Python is open source.

For example, we have developed a BBS system and put it on the Internet for users to download, then all the source code of the system is downloaded by the user and can be modified at will. This is also the characteristic of interpreted languages. To run a program, you must have source code.

② The Python interpreter and modules are open source.

The official open source code of the Python interpreter and modules is to hope that all Python users will participate to improve the performance of Python and make up for vulnerabilities in Python. The more the code is studied, the more robust it will be.

There are always a small group of people in this world who either don't follow fame or fortune, or in order to achieve a certain purpose, they will continue to strengthen and improve Python. Don't think that everyone is just looking for immediate benefits. There are always some elites who will go long-term to catch big fish, and some geeks will always do some cool things.

3) Python is free

Open source does not mean free. Open source software and free software are two concepts, but most open source software is also free software; Python is such a language, it is both open source and free.

If you want to distinguish between the concepts of open source and free, please punch: Does open source equal to free? Speak with facts

Users use Python to develop or publish their own programs without paying any fees or worry about copyright issues. Even for commercial purposes, Python is free.

4) Python is a high-level language

The advanced level mentioned here means that Python has a deeper encapsulation and shields many low-level details. For example, Python will automatically manage memory (allocate automatically when needed, and release automatically when not needed).

The advantage of high-level language is that it is easy to use, and there is no need to worry about the details; the disadvantage is that it is easy for people to taste it, knowing it and not knowing why.

5) Python is an interpreted language and can be cross-platform

Interpreted languages ​​are generally cross-platform (good portability), and Python is no exception. We have already explained it in the " Differences Between Compiled Languages ​​and Interpreted Languages ", so I won't repeat them here.

5) Python is an object-oriented programming language

Object-oriented is a feature that modern programming languages ​​generally have, otherwise it will be stretched when developing medium and large programs.

Python supports object orientation, but it does not enforce object orientation. Java is a typical object-oriented programming language, but it forces the code to be organized in the form of classes and objects.

6) Python is powerful (many modules)

Python has many modules, which basically implement all common functions, from simple string processing to complex 3D graphics drawing, it can be easily completed with the help of Python modules.

The Python community has developed well. In addition to the core modules officially provided by Python, many third-party organizations will also participate in the development of modules. Among them are software giants such as Google, Facebook, and Microsoft. Even for some niche functions, Python often has corresponding open source modules, and there may even be more than one module.

7) Python is highly scalable

The scalability of Python is reflected in its modules. Python has the most abundant and powerful class libraries in scripting languages. These class libraries cover most application scenarios such as file I/O, GUI, network programming, database access, and text operations. .

The underlying code of these libraries is not necessarily all Python, there are many C/C++ figures. When you need a piece of key code to run faster, you can use C/C++ to implement it, and then call them in Python. Python can "stick" other languages ​​together, so it is called "glue language".

Python relies on its good scalability to make up for the shortcomings of slow running efficiency to a certain extent.

Disadvantages of Python

In addition to the various advantages mentioned above, Python also has disadvantages.

1) Slow running speed

Slow running speed is a common problem with interpreted languages, and Python is no exception.

Python is slow not only because it “translates” the source code while running, but also because Python is a high-level language that shields many low-level details. This cost is also very high. Python has to do a lot of work, some of which consume resources, such as managing memory.

Python's running speed is almost the slowest, not only much slower than C/C++, but also slower than Java.

But the shortcomings of slow speed often don't cause any major problems. The first is that the faster the computer hardware is shipped, the more you spend more money to build high-performance hardware, and the improvement of hardware performance can make up for the lack of software performance.

Secondly, some application scenarios can tolerate slow speed. For example, on a website, most of the time the user opens a web page is waiting for a network request instead of waiting for the server to execute a web page program. The server spends 1ms to execute the program, and spends 20ms to execute the program, which is totally insensible to the user, because the network connection time often takes 500ms or even 2000ms.

2) Code encryption is difficult

Unlike the source code of a compiled language that is compiled into an executable program, Python runs the source code directly, so it is difficult to encrypt the source code.

Open source is a major trend in the software industry, and traditional programmers need to change their concepts.

In order to give you more learning suggestions, this is the Python resource qun I created: the first 1156, the middle is 465, and the last three numbers are 813. In communicating with each other, we can get a lot of learning experience. Learning is always on our own. When you master a good learning method and a systematic learning method, you will find that learning Python is actually not that difficult. If you have any questions, please feel free to ask in qun. I, qun contains a lot of information on academic xi, and I help you answer questions when you are not busy at work.

Guess you like

Origin blog.csdn.net/qq_38887171/article/details/109022835