[Numpy-discussion] Array Interface
theller at python.net
Fri Jun 16 14:49:33 CDT 2006
Travis Oliphant wrote:
> Thanks for the continuing discussion on the array interface.
> I'm thinking about this right now, because I just spent several hours
> trying to figure out if it is possible to add additional
> "object-behavior" pointers to a type by creating a metatype that
> sub-types from the Python PyType_Type (this is the object that has all
> the function pointers to implement mapping behavior, buffer behavior,
> etc.). I found some emails from 2002 where Guido indicates that it is
> not possible to sub-type the PyType_Type object and add new function
> pointers at the end without major re-writing of Python.
Yes, but I remember an email from Christian Tismer that it *is* possible.
Although I've never tried that.
What I do in ctypes is to replace the type objects (the subclass of PyType_Type)
dictionary with a subclass of PyDict_Type (in ctypes it is named StgDictObject
- storage dict object, a very poor name I know) that has additional structure fields
describing the C data type it represents.
More information about the Numpy-discussion