[Python-Dev] PEP 296 - The Buffer Problem

Thomas Heller thomas.heller@ion-tof.com
Fri, 26 Jul 2002 20:17:10 +0200


[sorry if you see this twice, didn't seem to get through
the first time]

If the safe buffer PEP would be accepted and implemented,
here's my proposal for the bytes object.

The bytes object uses the safe buffer interface to gain
access to the byte array it exposes.

The bytes type would probably accept the following arguments:

  PyObject *type - the (bytes) type or subtype to create
  PyObject *obj - the object exposing the safe buffer interface
  size_t offset - starting offset of obj's memory block
  size_t length - number of bytes to use (0 for all)

and maybe a flag requesting read or read/write access.

A convention could be that if a NULL is passed for obj,
then the bytes object itself allocates a memory block
of length length.

Of course the bytes object itself would also expose the safe
buffer interface. And slicing, but not repetition.

Isn't the above sufficient (provided that we somehow
add the pickle stuff into this picture)?

Thomas