Scott David Daniels <[EMAIL PROTECTED]> wrote: >Francois De Serres wrote: >> PyGILState_STATE gil = PyGILState_Ensure(); >> result = PyEval_CallObject(my_callback, arglist); >> PyGILState_Release(gil); >> Py_DECREF(arglist); >> Py_DECREF(result); > >I think this should be: > PyGILState_STATE gil = PyGILState_Ensure(); > result = PyEval_CallObject(my_callback, arglist); > Py_DECREF(arglist); > Py_DECREF(result); > PyGILState_Release(gil); > >The DECREFs need to be protected, that is where storage is >recycled and such, and you still need Python's data structures >to do that kind of work.
I freely admit to being woefully underinformed about the GIL, but I'm wondering if your statement is really true. If the purpose of the GIL is simply to make things thread-safe, then I would have guessed that the first one was correct. If someone else holds a reference to "arglist", then the DECREF is just a nice, atomic decrement. If no one else holds a reference to "arglist", then it's quite safe to delete it. Is there more to the GIL than I'm assuming? -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list