GIL (Global interpreter Lock)

Source: Internet
Author: User


GIL (Global interpreter Lock)
We know that multi-process (mutilprocess) and multi-threaded (threading) are designed to be accessed by multiple CPUs to improve program execution efficiency. But within Python there is a mechanism (GIL) that allows only one thread to access the CPU at the same time at multiple threads.
The GIL is not a Python feature, it is a concept introduced when implementing the Python parser (CPython). Just like C + + is a set of language (syntax) standards, but can be compiled into executable code with different compilers. Well-known compilers such as Gcc,intel c++,visual C + +.
Python is the same, and the same piece of code can be executed through different Python execution environments such as Cpython,pypy,psyco. Like the Jpython there is no Gil. However, because CPython is the default Python execution environment for most environments. So in a lot of people's concept CPython is Python, also take for granted the GIL to the Python language flaw. So let's be clear here: Gil is not a Python feature, and Python can be completely independent of the Gil.

Although Python supports multithreading, because of the Gil's limitations, when the program is actually running, multiple threads are opened, but only one thread can be executed by the CPU after the Gil.

GIL (Global interpreter Lock)

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.