[Python-3000] patch: bytes object PyBUF_LOCKDATA read-only and immutable support
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Sep 12 01:56:08 CEST 2007
Guido van Rossum wrote:
> Any number of concurrent SIMPLE accesses can
> coexist since the clients promise they will only read.
As a general principle, using a word like SIMPLE in an
API is a really bad idea imo, as it's far too vague.
I'm finding it impossible to evaluate the truthfulness
of statements like the above in this discussion, because
of that.
> basic read access (I can read, others can read or write)
> locked read access (I can read, others can only read)
> basic write access (I can read and write, others can read or write)
> exclusive write access (I can read and write, no others can read or write)
Should that last one perhaps be "I can read and write,
others can only read"?
Another thread wanting to read but get a stable view
of the data will be using "I can read, others can only read",
which will fail because the first one is writing. If the
reading thread doesn't care about stability, the writing
one shouldn't have to know.
Then we have two orthogonal things: READ vs WRITE, and
SHARED vs EXCLUSIVE (where 'exclusive' means that others
are excluded from writing).
> Except that accessing the object from Python (e.g. iteration or
> indexing) never gets locked out.
With the scheme I just proposed, the iterator could use
a non-exclusive mode if it wanted, which would give this
effect.
--
Greg
More information about the Python-3000
mailing list