[Python-3000] patch: bytes object PyBUF_LOCKDATA read-only and immutable support
jimjjewett at gmail.com
Tue Sep 11 18:56:06 CEST 2007
On 9/11/07, Travis E. Oliphant <oliphant at enthought.com> wrote:
> Guido van Rossum wrote:
> > ... I'm hoping Travis has a particular way in mind of
> > handling LOCKDATA that can be used as a template.
> The use case I had in mind comes about quite often in NumPy when you
> want to modify the data-area of an object which may have a
> non-contiguous chunk of memory, but the algorithm being used expects
> contiguous data. Imagine, for example, that the exporting object is an
> image whose rows are stored in different segments.
> The consumer of the buffer interface, however, may be an extension
> module that does fast image-processing operations and requires
> contiguous data. Because it wants to write the results back in to the
> memory area when it is done with the algorithm (which may be thread-safe
> and may release the GIL), it requests the object to lock its data to
> read-only so that other consumers do not try to get writeable buffers
> while it is processing.
Does it do its processing in the original buffer, causing it to be
temporarily invalid? If so, no one else should even be reading it.
Or does it just replace the original buffer with the new results once
it is finished? If so, then why does it need the lock the whole time?
Is someone getting known stale data (when you could tell them to
wait) always OK, but overwriting someone else's change never is?
More information about the Python-3000