[Python-3000] Immutable bytes type and bsddb or other IO
Gregory P. Smith
greg at electricrain.com
Mon Aug 27 09:59:25 CEST 2007
On Fri, Aug 24, 2007 at 09:58:24AM -0700, Gregory P. Smith wrote:
> On Thu, Aug 23, 2007 at 09:17:04PM -0700, Guido van Rossum wrote:
> > On 8/23/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> > > Gregory P. Smith wrote:
> > > > Wasn't a past mailing list thread claiming the bytes type was supposed
> > > > to be great for IO? How's that possible unless we add a lock to the
> > > > bytesobject?
> > >
> > > Doesn't the new buffer protocol provide something for
> > > getting a locked view of the data? If so, it seems like
> > > bytes should implement that.
> >
> > It *does* implement that! So there's the solution: these APIs should
> > not insist on bytes but use the buffer API. It's quite a bit of work I
> > suspect (especially since you can't use PyArg_ParseTuple with y# any
> > more) but worth it.
> >
> > BTW PyUnicode should *not* support the buffer API.
> >
> > I'll add both of these to the task spreadsheet.
>
> this sounds good, i'll work on it today for bsddb and hashlib.
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.
-gps
More information about the Python-3000
mailing list