On Tue, 17 Jul 2018 10:59:02 -0500
Tim Peters <tim.pet...@gmail.com> wrote:
> 
> 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.

Yes, and the payload of an int object is not a "Python object".
The OP mentioned PyInt_AS_LONG as an example, so clearly the question
was broader than you're painting it to be.

> 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.

Define "muck with".  As long as you're reading the memory area(s)
pointed to by the Py_buffer object, you're fine.  If you plan to write
to that memory, obviously you'll need to make sure the various threads
don't overwrite each other, i.e. distribute the work carefully.

But that's a normal provision for multi-threaded algorithms, not a
Python-specific restriction.  I'm assuming someone asking a question
about multi-threaded access to CPython objects already knows all
this :-)

Regards

Antoine.
_______________________________________________
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

Reply via email to