Contiguous memory blocks

Michael Hudson mwh at
Tue Aug 5 17:45:54 CEST 2003

panbru <panbru at> 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

Just a piece of historical cruft, AFAIK.


  Never meddle in the affairs of NT. It is slow to boot and quick to
  crash.                                             -- Stephen Harris

More information about the Python-list mailing list