[Python-3000] Single buffer implied in new buffer protocol?

Nick Coghlan ncoghlan at gmail.com
Thu Jun 5 14:16:01 CEST 2008


Stefan Behnel wrote:
> One question: what does that mean for the mutable bytearray class? How would
> that handle locking?

In a single-threaded app, or one where only a single thread at a time 
can access the object providing the buffer interface, no locking is 
needed (that's the main advantage of the approach of handing over 
reference ownership by means of Queue objects). In a multi-threaded app 
where multiple threads can access it simultaneously, it needs to be 
protected by locks just like any other resource that is shared between 
multiple threads.

No need to confuse the question of memory access with the question of 
thread synchronisation.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list