Exposing buffer interface for non-extension types?

Robert Kern robert.kern at gmail.com
Tue Jul 20 21:26:03 EDT 2010


On 7/20/10 8:38 PM, Ken Watford wrote:
> On Tue, Jul 20, 2010 at 6:58 PM, Stefan Behnel<stefan_ml at behnel.de>  wrote:
>> Ken Watford, 21.07.2010 00:09:
>>>
>>> Is there any way to expose the PEP 3118 buffer interface for objects
>>> that aren't extension types?
>>
>> Given that it's a pure C-level interface, I don't think there would be much
>> use for that.
>
> Perhaps, but *why* is it only a pure C-level interface? It's based
> on/inspired by the array interface, which was not a pure C-level
> interface. Did they simply neglect to provide the functionality due to
> lack of obvious use cases, or did they consciously decide to drop that
> functionality?

Lack of obvious use cases. The primary use case is for C extensions to 
communicate with each other. SWIG is the odd man out in that it does not create 
true extension types. While the functionality of the PEP derives from numpy's 
interface, it's inclusion in Python was largely seen as the extension of the 
older buffer interface which is also a pure C interface.

The Python-level __array_interface__ numpy API is not and will not be deprecated 
despite some outdated language in the documentation. Please continue to use it.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list