[Python-Dev] An updated extended buffer PEP (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Wed Mar 28 02:13:18 CEST 2007
- Previous message: [Python-Dev] An updated extended buffer PEP
- Next message: [Python-Dev] An updated extended buffer PEP
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Travis E. Oliphant wrote:
Greg Ewing wrote:
struct bufferinfo { ... };
int (*getbuffer)(PyObject *obj, struct bufferinfo *info); int (*releasebuffer)(PyObject *obj, struct bufferinfo *info);
This is not much different from my original "view" object. Stick a PyObjectHEAD at the start of this bufferinfo and you have it.
The important difference is that it doesn't have PyObject_HEAD at the start of it. :-)
I don't see why a PyObjectHEAD would make anything significantly slower. Then we could use Python's memory management very easily to create and destroy these things.
In the case where the shape/stride info is constant, and the caller is able to allocate the struct bufferinfo on the stack, my proposal requires no memory allocations at all. That's got to be faster than allocating and freeing a Python object.
When it is necessary to allocate memory for the shape/stride, some mallocs and frees (or Python equivalents) are going to be needed either way. I don't see how using a Python object makes this any easier.
-- Greg
- Previous message: [Python-Dev] An updated extended buffer PEP
- Next message: [Python-Dev] An updated extended buffer PEP
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]