[Python-3000] patch: bytes object PyBUF_LOCKDATA read-only and immutable support
Travis E. Oliphant
oliphant at enthought.com
Tue Sep 11 21:53:56 CEST 2007
Jim Jewett wrote:
> 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.
>>>
>
>
> 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.
>
No, the processing is done in a scratch area. But whether or not the
object thinks anyone should be reading it or not is up to the object.
If I've exported my memory as writeable and then somebody else wants to
get access to the same memory, then its up to the object to decide
whether or not that will be allowed.
It is useful to at least allow other objects to get the pointer to the
memory (perhaps they are just monitoring what is there or are just a
pipeline or a view of the data).
> 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?
>
There is no mechanism to "tell anybody" that the data is stale. Only
read-able copies are allowed until the "shadow" object is done and
copies its results back into the original data. Perhaps a mechanism to
signal that the data is stale (i.e. has been locked) would be a useful
addition.
-Travis
More information about the Python-3000
mailing list