2010/1/6 John Arbash Meinel <john.arbash.mei...@gmail.com>: > Anything that Py_INCREF or Py_DECREF's should have the GIL, or you may > get concurrent updating of the value, and then the final value is wrong. > (two threads do 5+1 getting 6, rather than 7, and when the decref, you > end up at 4 rather than back at 5).
Correct. > > AFAIK, the only things that don't require the GIL are macro functions, > like PyString_AS_STRING or PyTuple_SET_ITEM. PyErr_SetString, for > example, will be increfing and setting the exception state, so certainly > needs the GIL to be held. As a general rule, I would say, no Py* macros are safe without the gil either (the exception being Py_END_ALLOW_THREADS), since they mutate Python objects which must be protected. -- Regards, Benjamin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com