[Python-3000] Immutable bytes type and bsddb or other IO
Guido van Rossum
guido at python.org
Mon Aug 27 16:12:59 CEST 2007
On 8/27/07, Gregory P. Smith <greg at electricrain.com> wrote:
> So I converted _bsddb.c to use the buffer API everywhere only to find
> that bytes objects don't support the PyBUF_LOCKDATA option of the
> buffer API... I should've seen that coming. :) Anyways I opened a
> bug to track that. Its needed in order to release the GIL while doing
> I/O from bytes objects.
>
> http://bugs.python.org/issue1035
>
> My _bsddb patch is stored for posterity until issue1035 can be fixed
> in issue1036. I'll test it another day ignoring the mutability issues
> (as the current _bssdb.c does with its direct use of bytes) and update
> the patch after squashing bugs.
Adding data locking shouldn't be too complicated, but is it necessary?
The bytes object does support locking the buffer in place; isn't that
enough? It means someone evil could still produce a phase error by
changing the contents while you're looking at it (basically sabotaging
their own application) but I don't see how they could cause a segfault
that way.
Even if you really need the LOCKDATA feature, perhaps you can check in
a slight mod of your code that uses SIMPLE for now -- use a macro for
the flags that's defined as PyBUF_SIMPLE and add a comment that you'd
like it to be LOCKDATA once bytes support that.
That way we have less code in the tracker and more in subversion --
always a good thing IMO.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list