[Image-SIG] Buffer Object

Paul Barrett Barrett@stsci.edu
Fri, 23 Mar 2001 09:06:58 -0500 (EST)


Russian Spy writes:

 > Sorry about being a nag... I've posted a message about buffer
 > objects a few days ago... Is there any way anyone can help me?  Is
 > there a better way to transfer large quantity of binary information
 > between Python and C code (using SWIG) ?  Can anyone point me to an
 > example of how to use a Buffer Object?

Buffer objects are deprecated in Python, but not the buffer API, which
is probable what you want to use anyway.  The string object implements
the buffer API so you should be able to load your data into it and
then access its contents in C via the buffer API.  Take a look here:

http://www.python.org/doc/current/api/buffer-structs.html

for information about the API and get back to me if you have any
further questions.

I think we still need some type of fundamental buffer object which all
objects use to access and possibly export a block of memory.  I know
that such an object would improve the implementation of PEP 209:
Multi-Dimensional Arrays, make it easier to interchange data between
Numeric arrays and PIL images, and discourage the use of the string
object for such purposes.  The plan is to create a memory object whose
interface and features are similar to a memory-mapped object,
e.g. setting the buffer to read-only in string objects, etc.  When I
find the time, I'll prepare and submit a PEP describing this idea.

Cheers,
Paul

-- 
Dr. Paul Barrett       Space Telescope Science Institute
Phone: 410-338-4475    ESS/Science Software Group
FAX:   410-338-4767    Baltimore, MD 21218