Re: [Python-Dev] The buffer() function

2006-07-13 Thread Josiah Carlson
Thomas Heller <[EMAIL PROTECTED]> wrote: > AFAIK, the buffer object now does not hold a pointer into the object > it has been constructed from, it only gets it when its needed. > > IMO Objects/bufferobject.c, revision 35400 is considered safe. > > The checkin comment (by nascheme) was, more than

Re: [Python-Dev] The buffer() function

2006-07-13 Thread Thomas Heller
Josiah Carlson schrieb: > Thomas Heller <[EMAIL PROTECTED]> wrote: >> But that was not the question. What about the status of the buffer function? > >>From what I understand, it is relatively safe as long as you don't > mutate an object while there is a buffer attached to it. > > That is: > >

Re: [Python-Dev] The buffer() function

2006-07-13 Thread James Y Knight
On Jul 13, 2006, at 12:52 PM, Thomas Heller wrote: > IIUC, the buffer object was broken some time ago, but I think it has > been fixed. Can the 'status' of the buffer function be changed? > To quote the next question from the OP: > > "Is buffer safe to use? Is there an alternative?" > > My th

Re: [Python-Dev] The buffer() function

2006-07-13 Thread Josiah Carlson
Thomas Heller <[EMAIL PROTECTED]> wrote: > But that was not the question. What about the status of the buffer function? >From what I understand, it is relatively safe as long as you don't mutate an object while there is a buffer attached to it. That is: import array a = array.array(...

Re: [Python-Dev] The buffer() function

2006-07-13 Thread Thomas Heller
Fredrik Lundh schrieb: > Thomas Heller wrote: > Naturally I tried to call base64.encodestring(buffer(ctypes_instance)) and it worked, so that was my answer. > >> >>> does ctypes_instance implement the buffer API ? if it does, is the >>> buffer() call even necessary ? >> >> Yes, in bo

Re: [Python-Dev] The buffer() function

2006-07-13 Thread Fredrik Lundh
Thomas Heller wrote: >>> Naturally I tried to call base64.encodestring(buffer(ctypes_instance)) >>> and it worked, so that was my answer. >> >> does ctypes_instance implement the buffer API ? if it does, is the >> buffer() call even necessary ? > > Yes, in both cases. are you sure? does it i

Re: [Python-Dev] The buffer() function

2006-07-13 Thread Thomas Heller
Fredrik Lundh schrieb: > Thomas Heller wrote: > >> Naturally I tried to call base64.encodestring(buffer(ctypes_instance)) >> and it worked, so that was my answer. > > does ctypes_instance implement the buffer API ? if it does, is the > buffer() call even necessary ? Yes, in both cases. Thomas

Re: [Python-Dev] The buffer() function

2006-07-13 Thread Fredrik Lundh
Thomas Heller wrote: > Naturally I tried to call base64.encodestring(buffer(ctypes_instance)) > and it worked, so that was my answer. does ctypes_instance implement the buffer API ? if it does, is the buffer() call even necessary ? ___ Python-Dev m

[Python-Dev] The buffer() function

2006-07-13 Thread Thomas Heller
I just answered a question on comp.lang.python for someone who was asking about how to convert the internal buffer of a ctypes instance into base64 coding, without too much copying: "The conversion calls in the base64 module expect strings as input, so right now I'm converting the binary block