是否对频繁获得/发行GIL与谨慎获得/发行GIL进行过比较?你知道吗
例如,以^{
static PyObject *
keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds)
{
int voltage;
char *state = "a stiff";
char *action = "voom";
char *type = "Norwegian Blue";
static char *kwlist[] = {"voltage", "state", "action", "type", NULL};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|sss", kwlist,
&voltage, &state, &action, &type))
return NULL;
Py_BEGIN_ALLOW_THREADS
printf("-- This parrot wouldn't %s if you put %i Volts through it.\n", action, voltage);
printf("-- Lovely plumage, the %s -- It's %s!\n", type, state);
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
毕竟,GIL不需要来使用printf
,那么为什么要让keywdarg_parrot
bogart呢?现在想象一下这些微型GIL在C-library的其他地方都有。最好的办法是在你得到的任何机会释放GIL,还是越少越好?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐