python中ctypes创建的线程也在GIL下吗?

Is the thread created by ctypes also under GIL in python?

所有 python 个线程(在 CPython 中)都在 GIL 下。

如果线程是由ctypes创建的怎么办?

例如,python 只是通过 C Library 调用下面的函数,该函数在 C 区域而不是 python.

中创建线程
#include<thread>
int createUnitTestThread(int sasAddr){  
    sasEngine->thread = new std::thread(....);
    return 0;
}

是否相同?

不像 线程 在 GIL 下,Python 解释器中的操作是(包括大多数操作码的获取和执行之类的东西,所以这就是线程的原因执行 Python 代码 运行 大部分是互锁的)。

你的 C++ 线程将 运行 免费,只要它不在 Python 解释器中回调函数(用户回调或来自 Python.h 的函数)。