[Python-3000] Immutable bytes type and bsddb or other IO

Gregory P. Smith greg at electricrain.com
Thu Aug 23 19:18:38 CEST 2007


On Thu, Aug 23, 2007 at 09:49:19AM +0200, "Martin v. L?wis" wrote:
> > Yeah you did the keys (good!).  I just checked in a change to require
> > values to also by bytes.  Maybe that goes so far as to be inconvenient?
> 
> Ah, ok. I think it is fine. We still need to discuss what the best
> way is to do string:string databases, or string:bytes databases.
> 
> I added StringKeys and StringValues to allow for such cases, and I
> also changed shelve to use string keys (not bytes keys), as this
> is really a dictionary-like application; this all needs to be
> discussed.
> 
> Regards,
> Martin

Alright, regarding bytes being mutable.  I realized this morning that
things just won't work with the database libraries that way.
PyBytes_AS_STRING() returns a the bytesobjects char *ob_bytes pointer.
But database operations occur with the GIL released so that mutable
string is free to change out from underneath it.

I -detest- the idea of making another temporary copy of the data just
to allow the GIL to be released during IO.  data copies == bad.
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?  (Its not -likely- that bytes objects will be modified
while in use for IO in most circumstances but just the possibility
that it could be is a problem)

I don't have much sprint time available today but I'll stop by to talk
about this one a bit.

-greg


More information about the Python-3000 mailing list