[Python-Dev] Fw: Behavior of buffer()

Todd Miller jmiller@stsci.edu
Mon, 15 Jul 2002 12:36:29 -0400


Guido van Rossum wrote:

>>We have a very small extension function which creates writeable buffer 
>>objects using the buffer type C-API.  
>>
>
>That's how the buffer API was supposed to be used.
>
>>We also wrap suitable type instances with a "buffer object wrapper". 
>> I'm slowly gathering that this is unsafe.   :-(
>>
>
>I don't understand what you say, but I believe you.
>
I meant we call  PyBuffer_FromReadWriteObject and the resulting buffer 
lives longer than the extension function call that created it.   I have 
heard that it is possible for the original object to "move" leaving the 
buffer object pointer to it dangling.

>
>
>>>Maybe instead of the buffer() function/type, there should be a way to
>>>allocate raw memory?
>>>
>
>>Yes.    It would also be nice to be able to:
>>
>>1.  Know (at the python level) that a type supports the buffer C-API.
>>
>
>Good idea.  (I guess right now you can see if calling buffer() with an
>instance as argument works. :-)
>
>>2.  Copy bytes from one buffer to another (writeable buffer).  
>>
>
>Maybe you would like to work on a requirements gathering for a memory
>object
>
Sure.  I'd be willing to poll comp.lang.python (python-list?) and 
collate the results of any discussion that ensues.  Is that what you had 
in mind?

>
>
>--Guido van Rossum (home page: http://www.python.org/~guido/)
>
>
>_______________________________________________
>Python-Dev mailing list
>Python-Dev@python.org
>http://mail.python.org/mailman/listinfo/python-dev
>

Todd