[Python-Dev] PEP: Adding data-type objects to Python
theller at ctypes.org
Tue Oct 31 21:46:15 CET 2006
Travis Oliphant schrieb:
> For example, I'm pretty sure you were the one who made me aware that you
> can't just extend the PyTypeObject. Instead you extended the tp_dict of
> the Python typeObject to store some of the extra information that is
> needed to describe a data-type like I'm proposing.
> So, if you I'm just describing data-format information, why do I need
> all this complexity (that makes ctypes implementation easier/more
> natural/etc)? What if the StgDictObject is the Python data-format
> object I'm talking about? It actually looks closer.
> But, if all I want is the StgDictObject (or something like it), then why
> should I pass around the whole type object?
Maybe you don't need it. ctypes certainly needs the type object because
it is also used for constructing instances (while NumPy uses factory functions,
IIUC), or for converting 'native' Python object into foreign function arguments.
I know that this doesn't interest you from the NumPy perspective (and I don't want
to offend you by saying this).
> This is all I'm saying to those that want me to use ctypes to describe
> data-formats in the extended buffer protocol. I'm not trying to change
> anything in ctypes.
I don't want to change anything in NumPy, either, and was not the one who
suggested to use ctypes objects, although I had thought about whether it
would be possible or not.
What I like about ctypes, and dislike about Numeric/Numarry/NumPy is
the way C compatible types are defined in ctypes. I find the ctypes
way more natural than the numxxx or array module way, but what else would
anyone expect from me as the ctypes author...
I hope that a useful interface is developed from your proposals, and
will be happy to adapt ctypes to use it or interface ctypes with it
if this makes sense.
More information about the Python-Dev