Contiguous memory blocks

Michael Hudson mwh at python.net
Tue Aug 5 11:45:54 EDT 2003


panbru <panbru at comcast.net> writes:

> I'm doing some native code stuff and want to pass continguos memory
> blocks of data back and forth between Python and C, with the memory
> blocks modifiable in both realms.  What is a good way to do that?

array.array, or something from NumPy.

> As I understand it, "buffer interface" objects (e.g. strings or
> arrays) won't work because memory is not guaranteed to be
> continguous.

Ignore this: in practice, all objects that implement the buffer
interface are in fact contiguous ('single segment' in the buffer
interfaces terminology) and if you were so foolhardy as to implement
the buffer protocol and claim to have more than one segment, I don't
think anything (in the Python core) would actually work with your
objects.

Just a piece of historical cruft, AFAIK.

Cheers,
mwh

-- 
  Never meddle in the affairs of NT. It is slow to boot and quick to
  crash.                                             -- Stephen Harris
               -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html




More information about the Python-list mailing list