Buffer objects

Tom Harris celephicus at gmail.com
Mon Sep 1 11:28:31 EDT 2008


Greetings,

I need a little help with buffer objects. Many Python objects export
the buffer interface, or can be persuaded to create a buffer object
with a buffer() call.

First question, the buffer() function appears very quick. Does it just
wrap the internal pointer and then exit?

Second question, the buffer interface does include support for
multiple segments of memory. All the buffers I have examined are only
a single segment, is this a rarely used functionality?

Third question, having got my buffer interface I want to get the
actual pointer out so that I can call foreign functions with ctypes
with the pointer as a function argument and add offsets to it, so I
would like it as a plain int. What is the recommended method of
accessing the raw pointer from the buffer object?

It must be me but I have found the whole buffer thing difficult to
understand from the docs, it appears only useful to C coders, but I
use the buffer interface (GetData()) of wx.Image objects a lot in my
work.

TomH celephicus(AT)gmail(DOT)com



More information about the Python-list mailing list