<div dir="ltr"><div class="gmail_quote"><div dir="ltr">[Tim]> There is no intention to support GIL-free access to any Python objects. So<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> that's the contract: "All warranties are null & void if you do just about<br>
> anything while not holding the GIL".<br></blockquote><div><br>
<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">[Antoine]</span><br style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Actually, accessing a Py_buffer that's been obtained in the regular way</blockquote></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
(e.g. with PyObject_GetBuffer) is safe even without the GIL.<br></blockquote><div> </div><div>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.</div><div><br>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 <span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255)">PyObject_GetBuffer() to begin with, or </span>PyBuffer_Release() when they're done.<br><br></span></div><div><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">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.<br><br>So your "safe" comes with footnotes too, even though Py_buffer isn't itself a PyObject*.<br><br></span></div></div></div>