Exposing buffer interface for non-extension types?

Stefan Behnel stefan_ml at behnel.de
Tue Jul 20 18:58:15 EDT 2010


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.


> Currently, I can expose the NumPy array interface (using either
> __array_interface__ or __array_struct__) for any class, extension or
> otherwise. But I can't find any reference to python-side interfacing
> for PEP 3118. SWIG makes an extension module for your wrapped code,
> but not extension *types*, so the classes it produces are pure-python
> with methods added in from the extension module.

Try using Cython instead, it has native support for the buffer protocol.

Stefan




More information about the Python-list mailing list