[Python-3000] PEP Draft: Enhancing the buffer protcol
Travis E. Oliphant
oliphant.travis at ieee.org
Wed Feb 28 06:34:28 CET 2007
Greg Ewing wrote:
>
> The buffer API is for the use of C code, and it should
> be designed with the convenience of C code in mind.
> Using Python data structures unnecessarily seems like
> the wrong way to go about that.
>
> The following alternative would seem to provide most of
> the things that Travis's proposal does without involving
> Python objects:
>
In my latest version of the PEP, I suggest using Python CObject's as
loose wrappers around C-structures for both the char * format string and
the structure
int ndim
Py_ssize_t *shape;
Py_ssize_t *strides;
This way, we get the benefit of Python object counting for memory
management but easy-access to the relevant C-objects.
I've also added simple functions to the proposed C-API to construct
these C-objects.
-Travis
More information about the Python-3000
mailing list