[Tim]> There is no intention to support GIL-free access to any Python objects. So
> > that's the contract: "All warranties are null & void if you do just > about > > anything while not holding the GIL". > [Antoine] > Actually, accessing a Py_buffer that's been obtained in the regular way (e.g. with PyObject_GetBuffer) is safe even without the GIL. > Same as the docs, I use "Python object" to mean a pointer to PyObject. In that sense, a Py_buffer is no more a "Python object" than, e.g,, is a Py_ssize_t. If someone wants to muck with the `obj` member of a Py_buffer struct, _then_ they're back in "Python object" territory (`obj` is a PyObject*) and so are on their own if they don't obtain the GIL. Likewise all bets are off if they don't hold the GIL when calling PyObject_GetBuffer() to begin with, or PyBuffer_Release() when they're done. If they want to muck with the `buf` member without the GIL, then if they care about races among multiple threads mucking with `buf`, they'll have to supply their own mutual exclusion mechanism. So your "safe" comes with footnotes too, even though Py_buffer isn't itself a PyObject*.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com