Home  >  Article  >  Backend Development  >  Does the python language depend on the platform?

Does the python language depend on the platform?

anonymity
anonymityOriginal
2019-06-12 14:26:304619browse

Advantages and disadvantages of Python language:

Does the python language depend on the platform?

Advantages

Python’s positioning is “elegant”, “clear”, and “simple”, so Python programs always seem simple and easy to understand. Beginners learning Python are not only easy to get started, but also can write very, very complex programs if they go deeper in the future.

The development efficiency is very high. Python has a very powerful third-party library. Basically, if you want to realize any function through the computer, the Python official library has corresponding modules to support it. After downloading and calling directly, in the basic library Development will be carried out on the basis of the previous development cycle, which will greatly reduce the development cycle and avoid reinventing the wheel.

High-level language————When you write a program in Python, you don’t need to think about low-level details such as how to manage the memory used by your program

Portable Sex————Due to its open source nature, Python has been ported on many platforms (with modifications to enable it to work on different platforms). If you carefully avoid using system-dependent features, then all of your Python programs can run without modification on almost any system platform on the market

Scalability———— —If you need a critical piece of your code to run faster or want certain algorithms to be kept private, you can write parts of your program in C or C++ and use them in your Python program.

Embeddability————You can embed Python into your C/C program to provide scripting functionality to your program users.

Disadvantages:

Slow speed. Python’s running speed is indeed much slower than C language and slower than JAVA. Therefore, this is why many so-called experts disdain to use Python. The main reason, but in fact, the slow running speed referred to here cannot be directly perceived by users in most cases. It must be reflected with the help of testing tools. For example, it takes 0.1s to run a program in C, and 0.01 in Python. s, in this way, C language is directly 10s faster than Python, which is very exaggerated, but you cannot directly perceive it with the naked eye, because the smallest unit of time that a normal person can perceive is about 0.15-0.4s, haha. In fact, in most cases, Python can fully meet your program speed requirements, unless you want to write a search engine that has extremely high speed requirements. In this case, of course, it is recommended that you use C to implement it.

The code cannot be encrypted because PYTHON is an interpreted language and its source code is stored in the form of text. However, I don’t think this is a disadvantage. If your project requires that the source code must be encrypted, Then you shouldn't use Python to implement it in the first place.

Threads cannot take advantage of the problem of multiple CPUs. This is one of the most criticized shortcomings of Python. GIL, the Global Interpreter Lock, is a tool used by computer programming language interpreters to synchronize threads, making Only one thread is executing at any time, and Python's thread is the native thread of the operating system. It is pthread on Linux and Win thread on Windows. The execution of the thread is completely scheduled by the operating system. A python interpreter process has a main thread and multiple user program execution threads. Even on multi-core CPU platforms, parallel execution of multi-threads is prohibited due to the existence of GIL. Regarding the compromise solution to this problem, we will discuss it in detail in the thread and process chapters later.

The above is the detailed content of Does the python language depend on the platform?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn