Home > Backend Development > Python Tutorial > Why is python inefficient?

Why is python inefficient?

(*-*)浩
Release: 2019-05-30 13:05:58
Original
4260 people have browsed it

Python is an elegant programming language. Today, with the rapid development of artificial intelligence, cloud computing, and big data, Python has attracted attention from all walks of life, including domestic Alibaba, Sohu, Zhihu, Tencent, NetEase, Tudou, From Sina to foreign countries, Google, Dropbox, Facebook, Redhat, Uber, etc. are all using Python on a large scale to complete various tasks!

Why is python inefficient?

Python is becoming more and more widely used and very popular, certainly because it has many advantages, but Python also has a major shortcoming. Compared with C language,

Python has low operating efficiency, so what is the reason?

1. Python is a dynamic language

A dynamic language is a language that can change its structure at runtime, such as new functions, objects, codes Can be introduced, existing functions can be deleted or other structural changes, etc. This type of language is more lively, but it is inevitable that the uncertainty of runtime will also affect the running efficiency.

2. Python is an interpreted and executed language.

Compared with programs written in C compiled language, Python is an interpreted and executed language, and its running process is a Python running file program. , the Python interpreter converts the source code into bytecode, and then the Python interpreter executes these bytecodes. Each time it is run, it must be converted into bytecode, and then a virtual machine converts the bytecode into machine language before it can be run on the hardware. Compared with compiled languages, the process is more complicated and the performance will definitely be affected. Influence.

3. Everything in Python is an object

Python is an object-oriented programming language. Its design concept is that everything is an object, such as numbers and strings. Tuples, lists, dictionaries, functions, methods, classes, modules, etc. are all objects, including code. Each object needs to maintain a reference count. Therefore, extra work is added and performance is affected.

4. Python GIL

GIL is the most criticized point of Python. Because of GIL, multi-threading in Python cannot be truly concurrent. Even in a single thread, GIL It will also have a great performance impact, because Python will try to switch threads every time it executes 100 opcodes, thus affecting Python's operating efficiency.

5. Garbage collection

Python adopts a marked and generational garbage collection strategy. Each time garbage collection is performed, the executing program will be interrupted, causing the so-called pause. card, affecting operating efficiency.

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template