[Python-Dev] bool and Numeric

Paul F Dubois paul@pfdubois.com
Fri, 8 Mar 2002 10:54:56 -0800


FYI: Numeric makes arrays of anything. Indeed, when given a list of
items to use to construct an array, it falls back to "Object" as the
typecode of the result if the items don't have compatible types. (I.e.,
Numeric.array([1,2.]) has typecode Numeric.Float, but Numeric.array([1,
None]) would be typecode Numeric.PyObject. (The Numeric typecodes are a
superset or the same as the ones in Python's array class, I think).

If indeed PyInt_Check would identify a bool as an integer, we are either
ok or we can be made ok as far as the constructor goes, in that
Numeric.array([1,True]) will end up as typcode Numeric.Int; but so would
Numeric.array([True,False]). And as I said, this is going to cause
several new "well it is screwed up but take it or leave it" entries into
the manual.
E.g.,

x=Numeric.array([True,False]); print x[0] will end up printing 1, not
True.