GIL(全局解释器锁)一看就懂的解释! 您所在的位置:网站首页 python中gil锁和线程锁 GIL(全局解释器锁)一看就懂的解释!

GIL(全局解释器锁)一看就懂的解释!

2024-01-15 05:27| 来源: 网络整理| 查看: 265

今天提起GIL突然有点懵,于是小白搜遍了全网想深入了解下,硬是越看越懵,解释的真的难咽,所以个人整理了一下,希望大佬们有好的解释和用法,分享下!

GIL GIL(Global Interpreter Lock)全局解释器锁 **注意:**GIL并不是Python语言的特性,它是在现实Python解释器时引用的一个概念。

首先从官方概念来看:

In CPython, the global interpreter lock, or GIL, is a mutex that prevents multiple native threads from executing Python bytecodes at once. This lock is necessary mainly because CPython’s memory management is not thread-safe. (However, since the GIL exists, other features have grown to depend on the guarantees that it enforces.)

可以翻译为:

在cpython中,全局解释器锁(gil)是一个互斥体,它可以防止多个本机线程同时执行python字节码。这个锁是必要的,主要是因为cpython的内存管理不是线程安全的。(然而,由于gil存在&#


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有