In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the GIL of python". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the GIL of python".
1. What is GIL?
GIL, the global interpreter lock, is a widely complained technology, and even though python3.9 has arrived, the GIL still exists and seems to continue to exist.
In order to solve the problem of data integrity and state synchronization between multiple threads, GIL is introduced, which ensures that multiple native threads will not execute Python bytecode concurrently.
For the understanding of GIL, there is one thing we must seriously make clear that GIL is not a feature of python, but the implementation of Python parser (CPython, we usually default to download and install the interpreter) introduced when a concept, this is like C++ is a set of language standards, but can be compiled with compilers such as GCC,INTEL Clearing, visual C++ and other compilers, the executable procedures are not the same. You can use CPython,PyPy, JPython to execute python code. There is GIL in CPython, but JPython does not.
It's not that Python maintainers haven't considered removing GIL, but there are already too many libraries that rely on this feature, and long-term accumulation is not easy to solve.
two。 Impact on multithreading
Multithreading is originally intended to make better use of the multi-core resources of CPU, but because of the existence of GIL, there can only be one python thread running at the same time. Obviously, this is a shameless waste of resources.
Therefore, you can't use python multithreading as a means to improve program performance, for CPU-intensive tasks, use multiprocesses. Even so, python multithreading is not as chicken as everyone complains, and python multithreading still has the opportunity to use its talents for Imax O-intensive tasks.
When one thread waits, GIL is released so that other threads can get GIL to perform their own tasks, which is the technical basis for you to write multithreaded crawlers to speed up crawling.
Thank you for your reading, the above is the content of "what is the GIL of python". After the study of this article, I believe you have a deeper understanding of what the GIL of python is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.