[Python-Dev] PEP: Adding data-type objects to Python

"Martin v. Löwis" martin at v.loewis.de
Tue Oct 31 08:51:25 CET 2006

Travis Oliphant schrieb:
> So, the big difference is that I think data-formats should be 
> *instances* of a single type.

This is nearly the case for ctypes as well. All layout descriptions
are instances of the type type. Nearly, because they are instances
of subtypes of the type type:

py> type(ctypes.c_long)
<type '_ctypes.SimpleType'>
py> type(ctypes.c_double)
<type '_ctypes.SimpleType'>
py> type(ctypes.c_double).__bases__
(<type 'type'>,)
py> type(ctypes.Structure)
<type '_ctypes.StructType'>
py> type(ctypes.Array)
<type '_ctypes.ArrayType'>
py> type(ctypes.Structure).__bases__
(<type 'type'>,)
py> type(ctypes.Array).__bases__
(<type 'type'>,)

So if your requirement is "all layout descriptions ought to have
the same type", then this is (nearly) the case: they are instances
of type (rather then datatype, as in your PEP).


More information about the Python-Dev mailing list