Travis E. Oliphant <oliphant.travis <at> ieee.org> writes: > > Alexander Belopolsky wrote: > > ... > > 1. Should primitive types be associated with simple type codes (short, int, long, > > float, double) or type/size pairs [(int,16), (int, 32), (int, 64), (float, 32), > > (float, 64)]? > > - I prefer pairs > > > > 2. Should primitive type codes be characters or integers (from an enum) at > > C level? > > - I prefer integers > > Are these orthogonal? >
Do you mean are my quiestions 1 and 2 orthogonal? I guess they are. > > > > 3. Should size be expressed in bits or bytes? > > - I prefer bits > > > > So, you want an integer enum for the "kind" and an integer for the > bitsize? That's fine with me. > > One thing I just remembered. We have T_UBYTE and T_BYTE, etc. defined > in structmember.h already. Should we just re-use those #defines while > adding to them to make an easy to use interface for primitive types? > I was thinking about using something like NPY_TYPES enum, but T_* codes would work as well. Let me just present both options for the record: --- numpy/ndarrayobject.h --- enum NPY_TYPES { NPY_BOOL=0, NPY_BYTE, NPY_UBYTE, NPY_SHORT, NPY_USHORT, NPY_INT, NPY_UINT, NPY_LONG, NPY_ULONG, NPY_LONGLONG, NPY_ULONGLONG, NPY_FLOAT, NPY_DOUBLE, NPY_LONGDOUBLE, NPY_CFLOAT, NPY_CDOUBLE, NPY_CLONGDOUBLE, NPY_OBJECT=17, NPY_STRING, NPY_UNICODE, NPY_VOID, NPY_NTYPES, NPY_NOTYPE, NPY_CHAR, /* special flag */ NPY_USERDEF=256 /* leave room for characters */ }; --- structmember.h --- /* Types */ #define T_SHORT 0 #define T_INT 1 #define T_LONG 2 #define T_FLOAT 3 #define T_DOUBLE 4 #define T_STRING 5 #define T_OBJECT 6 /* XXX the ordering here is weird for binary compatibility */ #define T_CHAR 7 /* 1-character string */ #define T_BYTE 8 /* 8-bit signed int */ /* unsigned variants: */ #define T_UBYTE 9 #define T_USHORT 10 #define T_UINT 11 #define T_ULONG 12 /* Added by Jack: strings contained in the structure */ #define T_STRING_INPLACE 13 #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError when the value is NULL, instead of converting to None. */ #ifdef HAVE_LONG_LONG #define T_LONGLONG 17 #define T_ULONGLONG 18 #endif /* HAVE_LONG_LONG */ _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com