types for sequence handling
Check if it's an ndarray
See if it's a python None
Check if it's a NumPy scalar
Check if it's a Python scalar
Check if it's an ASCII string
If it's already a big enough string, don't bother type promoting
Check if it's a Unicode string
If it's already a big enough unicode object, don't bother type promoting
PEP 3118 buffer interface
The array interface
The array struct interface
The old buffer interface
The __array__ attribute
If we reached the maximum recursion depth without hitting one of the above cases, and obj isn't a sequence-like object, the output dtype should be either OBJECT or a user-defined type.
Note that some libraries define sequence-like classes but want them to be treated as objects, and they expect numpy to treat it as an object if __len__ is not defined.
Recursive case, first check the sequence contains only one type
all types are the same and scalar, one recursive call is enough
TODO: we could add longs if we add a range check
Recursive call for each sequence item
Set 'out_dtype' if it's NULL
Do type promotion with 'out_dtype'
References NPY_OBJECT, promote_types(), and PyArray_DescrFromType().