A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2007-March/072368.html below:

[Python-Dev] An updated extended buffer PEP

[Python-Dev] An updated extended buffer PEP [Python-Dev] An updated extended buffer PEPGreg Ewing greg.ewing at canterbury.ac.nz
Wed Mar 28 02:13:18 CEST 2007
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 
> PyObject_HEAD 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 PyObject_HEAD 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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4